:root {
  --bg: #000;
  --card: rgba(10, 10, 10, 0.6);
  --line: rgba(255, 255, 255, 0.08);
  --line-hi: rgba(255, 255, 255, 0.18);
  --text: #f5f5f5;
  --dim: #6b6b6b;
  --faint: #3a3a3a;
  --r: 16px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
  --sans: -apple-system, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; }
html { color-scheme: dark; }
body {
  min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
::selection { background: #fff; color: #000; }
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

.shell { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 56px 28px 32px; }

/* ---------- 入场 ---------- */
.reveal { opacity: 0; transform: translateY(16px); filter: blur(6px); animation: in .9s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 90ms + 100ms); }
@keyframes in { to { opacity: 1; transform: none; filter: none; } }

/* ---------- header ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 36px; flex-wrap: wrap; }
h1 { font: 600 44px/1 var(--sans); letter-spacing: -.02em; display: flex; align-items: center; gap: 12px; }
h1 .cursor { width: 3px; height: 38px; background: #fff; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.tag { font: 11px/1 var(--mono); color: var(--dim); letter-spacing: .28em; margin-top: 14px; text-transform: uppercase; }

.tabs { position: relative; display: flex; padding: 4px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.02); backdrop-filter: blur(12px); }
.tab { position: relative; z-index: 1; padding: 8px 24px; border-radius: 999px; color: var(--dim); font-size: 14px; font-weight: 500; transition: color .4s var(--ease); }
.tab:hover { color: var(--text); }
.tab.on { color: #000; }
.tab-ink { position: absolute; top: 4px; bottom: 4px; left: 4px; border-radius: 999px; background: #fff; transition: transform .6s var(--ease), width .6s var(--ease); }

/* ---------- 卡片：跟随鼠标的光斑与描边 ---------- */
.panel[hidden] { display: none; }
.panel.enter > * { animation: in .7s var(--ease) both; }
.panel.enter > *:nth-child(2) { animation-delay: .08s; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card {
  --mx: 50%; --my: 50%;
  position: relative; display: flex; flex-direction: column; isolation: isolate;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.card::before, .card::after { content: ""; position: absolute; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .5s; }
.card::before { inset: 0; z-index: -1; background: radial-gradient(420px circle at var(--mx) var(--my), rgba(255,255,255,.055), transparent 60%); }
.card::after {
  inset: -1px; padding: 1px;
  background: radial-gradient(260px circle at var(--mx) var(--my), rgba(255,255,255,.55), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.card:hover::before, .card:hover::after { opacity: 1; }

.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; min-height: 42px; }
.label { font: 500 10px/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--dim); }
.label b { color: var(--text); font-weight: 500; margin-left: 8px; font-variant-numeric: tabular-nums; }
.label em { font-style: normal; letter-spacing: .02em; text-transform: none; color: var(--faint); margin-left: 10px; font-family: var(--sans); }
.meta { font: 11px var(--mono); color: var(--dim); font-variant-numeric: tabular-nums; }

textarea, .output {
  flex: 1; min-height: 280px; width: 100%; padding: 14px 20px 20px;
  font: 17px/1.85 var(--sans); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
textarea { background: none; border: 0; outline: none; resize: none; caret-color: #fff; }
textarea::placeholder, .output:empty::before { color: var(--faint); }
.output { position: relative; overflow: auto; max-height: 460px; }
.output:empty::before { content: "结果会出现在这里"; }

/* 生成时的扫描光 */
.out .scan { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
.out .scan::before {
  content: ""; position: absolute; left: 0; right: 0; height: 120px; top: -120px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.06) 70%, rgba(255,255,255,.5) 99%, transparent);
}
.out .scan::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.04); opacity: 0; }
.out.pulse .scan::before { animation: sweep .9s var(--ease); }
.out.pulse .scan::after { animation: flash .6s ease-out; }
@keyframes sweep { to { top: 100%; } }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* 透视：隐藏字符化身细线，按类型区分形态 */
.hc { display: none; }
.xray-on .hc {
  display: inline-block; width: 2px; height: 1em; margin: 0 1.5px; vertical-align: -0.12em;
  background: #fff; transform-origin: bottom;
  animation: grow .5s var(--ease) both;
}
.xray-on .hc.t { background: #777; }
.xray-on .hc.s { background: repeating-linear-gradient(#fff 0 2px, transparent 2px 4px); }
.xray-on .hc.o { background: none; box-shadow: inset 0 0 0 1px #aaa; width: 4px; border-radius: 1px; }
@keyframes grow { from { transform: scaleY(0); opacity: 0; } }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.stats { display: flex; gap: 20px; font: 11px var(--mono); color: var(--dim); flex-wrap: wrap; letter-spacing: .04em; }
.stats b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; }

/* 主按钮：磁吸 + 光泽扫过 + 成功态 */
.primary {
  position: relative; overflow: hidden; height: 40px; padding: 0 20px; border-radius: 999px;
  background: #fff; color: #000; font-size: 14px; font-weight: 600;
  transition: transform .4s var(--ease), box-shadow .4s;
}
.primary:hover { box-shadow: 0 0 0 4px rgba(255,255,255,.08), 0 10px 40px -8px rgba(255,255,255,.35); }
.primary:active { scale: .96; }
.primary span { display: inline-block; transition: transform .45s var(--ease), opacity .3s; }
.primary::before { content: "已复制 ✓"; position: absolute; inset: 0; display: grid; place-items: center; transform: translateY(100%); transition: transform .45s var(--ease); }
.primary.done span { transform: translateY(-160%); opacity: 0; }
.primary.done::before { transform: none; }
.primary::after { content: ""; position: absolute; inset: 0; transform: translateX(-120%) skewX(-20deg); background: linear-gradient(90deg, transparent, rgba(0,0,0,.12), transparent); }
.primary:hover::after { transform: translateX(120%) skewX(-20deg); transition: transform .8s var(--ease); }

.ghost { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-hi); color: var(--dim); font-size: 16px; transition: color .3s, border-color .3s, transform .7s var(--ease); }
.ghost:hover { color: #fff; border-color: #fff; }
.ghost.spin { transform: rotate(-360deg); }

/* 透视开关 */
.xray { display: flex; align-items: center; gap: 10px; cursor: pointer; font: 500 10px var(--mono); letter-spacing: .22em; color: var(--dim); user-select: none; transition: color .3s; }
.xray input { appearance: none; width: 28px; height: 16px; border-radius: 99px; border: 1px solid var(--line-hi); position: relative; cursor: pointer; transition: background .4s var(--ease), border-color .4s; }
.xray input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--dim); transition: transform .4s var(--ease), background .4s; }
.xray input:checked { background: #fff; border-color: #fff; }
.xray input:checked::after { transform: translateX(12px); background: #000; }
.xray:has(input:checked) { color: var(--text); }

/* ---------- 控制栏 ---------- */
.controls { margin-top: 16px; padding: 20px; display: grid; grid-template-columns: auto 1fr 1fr 1.6fr; gap: 28px; align-items: end; }
.ctl { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.seg { position: relative; display: flex; padding: 3px; border-radius: 999px; border: 1px solid var(--line); }
.seg button { position: relative; z-index: 1; padding: 5px 14px; border-radius: 999px; color: var(--dim); font-size: 13px; transition: color .4s var(--ease); white-space: nowrap; }
.seg button.on { color: #000; }
.seg-ink { position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: 999px; background: #fff; transition: transform .5s var(--ease), width .5s var(--ease); }

input[type=range] { appearance: none; width: 100%; height: 30px; background: none; cursor: pointer; --p: 100%; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(90deg, #fff var(--p), #262626 var(--p)); }
input[type=range]::-moz-range-track { height: 2px; background: linear-gradient(90deg, #fff var(--p), #262626 var(--p)); }
input[type=range]::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: #fff; transition: transform .3s var(--ease), box-shadow .3s; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.3); box-shadow: 0 0 0 6px rgba(255,255,255,.1); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(.9); box-shadow: 0 0 0 10px rgba(255,255,255,.08); }

input[type=text] { height: 36px; padding: 0 0 0 2px; border: 0; border-bottom: 1px solid var(--line-hi); background: none; outline: none; font: 13px var(--mono); transition: border-color .3s; }
input[type=text]:focus { border-color: #fff; }
input[type=text]::placeholder { color: var(--faint); }

/* ---------- 检测 ---------- */
.verdict-dirty { color: var(--text); }
.verdict-dirty::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #fff; margin-right: 8px; vertical-align: 1px; animation: ping 1.4s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.6); } 100% { box-shadow: 0 0 0 8px rgba(255,255,255,0); } }
.secret-box { margin-top: 16px; padding: 20px; gap: 12px; }
.secret-box p { font: 500 20px var(--mono); letter-spacing: .02em; word-break: break-all; }
.legend { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 2px; height: 11px; display: inline-block; background: #fff; }
.legend i.t { background: #777; }
.legend i.s { background: repeating-linear-gradient(#fff 0 2px, transparent 2px 4px); }
.legend i.o { width: 4px; background: none; box-shadow: inset 0 0 0 1px #aaa; }

.foot { margin-top: 44px; text-align: center; font: 10px/1.8 var(--mono); color: var(--faint); letter-spacing: .14em; }

.toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 10; translate: -50% 24px; opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; background: #fff; color: #000; font-size: 13px; font-weight: 500;
  transition: all .5s var(--ease);
}
.toast.show { opacity: 1; translate: -50% 0; }

@media (max-width: 860px) {
  .shell { padding: 32px 16px; }
  h1 { font-size: 34px; }
  .grid { grid-template-columns: 1fr; }
  .controls { grid-template-columns: 1fr 1fr; }
  .ctl.wide { grid-column: 1 / -1; }
  textarea, .output { min-height: 180px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .reveal { opacity: 1; transform: none; filter: none; } }
