:root {
  --bg: #0f1220;
  --bg2: #171a2e;
  --panel: #1c2036;
  --panel2: #232847;
  --ink: #ecefff;
  --muted: #9aa3c7;
  --line: #2c3358;
  --brand: #7c8cff;
  --brand2: #59d6c4;
  --accent: #ffcb6b;
  --danger: #ff8a8a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 700px at 80% -10%, #26305c 0%, transparent 60%),
    radial-gradient(900px 600px at -10% 10%, #1c3b3a 0%, transparent 55%), var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1180px, 92vw); margin: 0 auto; }

/* Topbar */
.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(15, 18, 32, 0.72);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 34px; line-height: 1; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: 0.2px; }
.tag { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.ghost-link { color: var(--brand); text-decoration: none; font-size: 14px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; }
.ghost-link:hover { border-color: var(--brand); }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 22px;
  padding: 26px 0 10px;
  align-items: start;
}
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.form { position: sticky; top: 78px; }
.panel-title { margin: 0 0 14px; font-size: 15px; color: var(--brand2); letter-spacing: 0.4px; }

/* Form */
.field { display: block; margin-bottom: 16px; border: 0; padding: 0; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
legend.label { padding: 0; }
textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  background: #12162b;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.18); }
.hint { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 14px; }
.grow { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #12162b;
  padding: 7px 11px; border-radius: 999px; cursor: pointer;
  font-size: 13px; color: var(--ink); user-select: none;
  transition: border-color .15s, background .15s;
}
.chip input { display: none; }
.chip.on { border-color: var(--brand); background: rgba(124, 140, 255, 0.16); }
.chip.base { opacity: .75; cursor: not-allowed; border-style: dashed; }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
button { font-family: inherit; cursor: pointer; }
.primary {
  background: linear-gradient(135deg, var(--brand), #5b6bff);
  color: #fff; border: 0; padding: 12px 18px; border-radius: 10px;
  font-size: 15px; font-weight: 600; box-shadow: 0 6px 18px rgba(91, 107, 255, 0.4);
}
.primary:hover { filter: brightness(1.07); }
.link { background: none; border: 0; color: var(--brand); font-size: 13px; text-decoration: underline; }
.privacy { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

/* Output */
.output-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.exports { display: flex; gap: 8px; }
.mini {
  background: #12162b; border: 1px solid var(--line); color: var(--ink);
  padding: 7px 11px; border-radius: 8px; font-size: 12px;
}
.mini:hover:not(:disabled) { border-color: var(--brand2); }
.mini:disabled { opacity: .4; cursor: not-allowed; }

.result { margin-top: 14px; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; border: 1px dashed var(--line); border-radius: 12px; }
.empty-emoji { font-size: 40px; display: block; margin-bottom: 10px; }

.block { margin-bottom: 22px; }
.block > h3 { font-size: 14px; color: var(--accent); margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }

.variant { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #12162b; }
.variant-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.badge { background: rgba(89, 214, 196, 0.16); color: var(--brand2); border: 1px solid rgba(89, 214, 196, 0.4); border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 700; }
.variant-name { font-weight: 600; font-size: 14px; }
.variant p { margin: 4px 0; font-size: 13px; color: var(--muted); }
.variant p b { color: var(--ink); font-weight: 600; }
.scaffold {
  position: relative; margin-top: 8px; background: #0c0f1e; border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 12px 12px; font-size: 12.5px; white-space: pre-wrap;
  word-break: break-word; font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  color: #d7dcff; max-height: 260px; overflow: auto;
}
.copy-line { position: absolute; top: 8px; right: 8px; }

.cases { display: grid; gap: 8px; }
.case { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #12162b; font-size: 13px; }
.case .cid { font-weight: 700; color: var(--brand); }
.case .btag { font-size: 11px; border-radius: 5px; padding: 1px 7px; margin-left: 6px; }
.btag.典型 { background: rgba(89,214,196,.16); color: var(--brand2); }
.btag.边界 { background: rgba(255,203,107,.16); color: var(--accent); }
.btag.对抗 { background: rgba(255,138,138,.16); color: var(--danger); }
.case .slot { color: var(--muted); margin-top: 4px; }

.rubric { display: grid; gap: 8px; }
.dim { display: flex; align-items: baseline; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #12162b; font-size: 13px; }
.dim .w { flex: 0 0 auto; background: rgba(124,140,255,.16); color: var(--brand); border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 700; }
.dim .dn { font-weight: 600; flex: 0 0 auto; }
.dim .dd { color: var(--muted); }
.rubric-foot { font-size: 12px; color: var(--muted); margin-top: 4px; }

.record { background: #0c0f1e; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, Consolas, monospace; color: #cfd6ff; max-height: 340px; overflow: auto; }

/* Explain */
.explain { padding: 34px 0 8px; }
.explain h2 { font-size: 18px; margin: 0 0 16px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card h3 { margin: 0 0 8px; font-size: 14px; color: var(--brand2); }
.card p { margin: 0; font-size: 13.5px; color: var(--muted); }

.foot { display: flex; justify-content: space-between; align-items: center; padding: 26px 0 40px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); margin-top: 24px; flex-wrap: wrap; gap: 8px; }
.selftest.ok { color: var(--brand2); }
.selftest.bad { color: var(--danger); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #232847; border: 1px solid var(--brand); color: var(--ink); padding: 10px 18px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .form { position: static; }
  .cards { grid-template-columns: 1fr; }
  .brand h1 { font-size: 18px; }
  .tag { display: none; }
}
