:root {
  color-scheme: dark;
  --bg:#070b14; --panel:#0d1420; --panel2:#111a2b; --line:#283c5a;
  --cyan:#22d3ee; --purple:#a78bfa; --green:#73dfbb; --red:#ff9b9b;
  --text:#dbe7f5; --dim:#a1b3ca; --muted:#839ab8;
  --mono:"Cascadia Code",Consolas,monospace;
}
* { box-sizing:border-box; }
[hidden] { display:none !important; }
html { background:var(--bg); }
body { margin:0; min-height:100vh; color:var(--text); font:15px/1.7 "PingFang SC","Microsoft YaHei",system-ui,sans-serif;
  background-image:radial-gradient(ellipse 80% 50% at 50% -20%,#22d3ee14,transparent),radial-gradient(ellipse 60% 40% at 90% 110%,#a78bfa12,transparent),linear-gradient(#1c2b4538 1px,transparent 1px),linear-gradient(90deg,#1c2b4538 1px,transparent 1px);
  background-size:auto,auto,44px 44px,44px 44px; overflow-wrap:anywhere; }
.wrap { max-width:960px; margin:0 auto; padding:24px 24px max(40px,env(safe-area-inset-bottom)); }
.back { color:var(--cyan); font-size:13px; text-decoration:none; display:inline-flex; align-items:center; min-height:44px; }
.back:hover { text-decoration:underline; }
.head { padding:12px 0 22px; display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.logo { width:42px; height:42px; border-radius:11px; flex:none; background:linear-gradient(135deg,#0e7490,#6d28d9); box-shadow:0 0 20px #22d3ee33; display:grid; place-items:center; font:700 20px var(--mono); color:#fff; }
.heading { min-width:0; flex:1 1 260px; }
h1 { font-size:24px; line-height:1.35; margin:0 0 3px; color:var(--cyan); }
.sub { margin:0; font:12px/1.6 var(--mono); color:var(--dim); }
#status { font-size:12px; padding:6px 12px; border:1px solid #b69136; color:#f5d68a; border-radius:20px; }
.notice { padding:14px 18px; border:1px solid #8b722d; border-radius:12px; background:#b6913610; color:#f1dba2; }
.notice p { margin:5px 0 0; font-size:13px; }
.card { background:linear-gradient(180deg,var(--panel),var(--panel2)); border:1px solid var(--line); border-radius:14px; padding:24px; margin-top:18px; box-shadow:0 8px 30px #0004; min-width:0; }
.card-title { margin:0 0 16px; font:500 13px/1.6 var(--mono); color:var(--cyan); letter-spacing:1px; }
.grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; align-items:start; }
.field { min-width:0; }
.full { grid-column:1/-1; }
label { display:block; color:var(--dim); font-size:13px; margin-bottom:7px; }
.req { color:var(--red); }
.optional { margin-left:6px; color:var(--muted); font-size:12px; }
input,textarea { width:100%; min-width:0; max-width:100%; border:1px solid var(--line); border-radius:8px; padding:11px 13px; background:#070b14b3; color:var(--text); font:inherit; font-size:16px; }
input { min-height:46px; }
textarea { display:block; resize:vertical; min-height:84px; }
input:focus,textarea:focus { border-color:var(--cyan); outline:2px solid #22d3ee33; outline-offset:2px; }
[aria-invalid="true"] { border-color:var(--red); }
.field-error { color:var(--red); font-size:12px; margin:5px 0 0; }
.field-error:empty { display:none; }
.field-meta { margin-top:6px; display:flex; flex-wrap:wrap; justify-content:space-between; gap:5px 16px; font-size:12px; color:var(--muted); }
#material-count { white-space:nowrap; }
.actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-top:22px; }
button { cursor:pointer; font:inherit; border-radius:9px; min-height:44px; max-width:100%; }
.btn { border:0; padding:11px 22px; background:linear-gradient(90deg,#0e7490,#6d28d9); color:#fff; font-weight:600; }
.ghost { background:transparent; border:1px solid #496182; padding:10px 16px; color:var(--dim); }
.ghost:hover:enabled { border-color:var(--cyan); color:var(--cyan); }
button:disabled { cursor:not-allowed; color:var(--muted); background:var(--panel2); }
button:focus-visible,a:focus-visible,summary:focus-visible,[tabindex]:focus-visible { outline:3px solid var(--cyan); outline-offset:4px; }
.form-message { margin:14px 0 0; font-size:13px; color:var(--dim); }
.form-message:empty { display:none; }
.form-message.error { color:var(--red); }
.form-message.ok { color:var(--green); }
.hint { font-size:12.5px; color:var(--dim); margin:0; }
.stages { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; list-style:none; padding:0; margin:18px 0; }
.stage { display:flex; align-items:flex-start; gap:10px; padding:14px; background:#070b145e; border:1px solid var(--line); border-radius:10px; min-width:0; }
.stage > div { min-width:0; }
.step-no { flex:none; display:grid; place-items:center; width:28px; height:28px; border:1px solid var(--line); border-radius:50%; color:var(--muted); font:13px/1 var(--mono); }
.stage h3 { font-size:14px; margin:0 0 6px; }
.stage p { margin:0 0 10px; font-size:12px; color:var(--dim); }
.stage-state { font-size:11px; border:1px solid var(--line); border-radius:20px; padding:2px 8px; color:var(--muted); }
.stage.is-running { border-color:var(--cyan); background:#22d3ee0c; animation:stage-glow 2s ease-in-out infinite; }
.stage.is-running .step-no { border:2px solid #22d3ee40; border-top-color:var(--cyan); animation:stage-spin 1s linear infinite; }
.stage.is-running .stage-state { color:var(--cyan); border-color:#22d3ee70; }
.stage.is-completed { border-color:#398e76; background:#73dfbb08; }
.stage.is-completed .step-no,.stage.is-completed .stage-state { color:var(--green); border-color:#398e76; }
.stage.is-error { border-color:#b35f69; }
.stage.is-error .step-no,.stage.is-error .stage-state { color:var(--red); border-color:#b35f69; }
.stage.is-stopped .step-no,.stage.is-stopped .stage-state,.stage.is-interrupted .step-no,.stage.is-interrupted .stage-state { color:#f5d68a; border-color:#8b722d; }
.pipeline-feedback { display:flex; align-items:center; gap:10px; min-height:24px; }
.pipeline-spinner { display:none; flex:none; width:16px; height:16px; border:2px solid #22d3ee40; border-top-color:var(--cyan); border-radius:50%; }
.pipeline-feedback.is-busy .pipeline-spinner { display:block; animation:stage-spin 1s linear infinite; }
@keyframes stage-spin { to { transform:rotate(360deg); } }
@keyframes stage-glow { 50% { box-shadow:0 0 18px #22d3ee25; } }
.result { margin-top:28px; scroll-margin-top:20px; }
.result-head { display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.result-head > div { min-width:0; flex:1 1 280px; }
.result-head h2 { color:var(--cyan); font-size:17px; margin:0 0 5px; }
.sample-label { margin:0; color:#f5d68a; font-size:12px; }
.bubble { font-size:15px; line-height:1.85; min-width:0; }
.bubble.streaming { white-space:pre-wrap; overflow-wrap:anywhere; }
#stop { border-color:var(--red); color:var(--red); }
#status.ready { border-color:#398e76; color:var(--green); }
input:disabled,textarea:disabled { opacity:.7; }
.bubble p { margin:0 0 12px; }
.bubble h3 { margin:24px 0 12px; font-size:17px; color:var(--cyan); border-left:3px solid var(--cyan); padding-left:10px; }
.bubble h3:first-child { margin-top:0; }
.bubble ul,.bubble ol { padding-left:24px; }
.bubble strong { color:#fff; }
.bubble em { color:var(--purple); }
.bubble a { color:#80bdff; text-decoration:underline; text-underline-offset:3px; overflow-wrap:anywhere; }
.bubble code { background:var(--panel2); padding:2px 6px; border-radius:4px; }
.bubble pre { max-width:100%; overflow-x:auto; padding:14px; background:var(--bg); border:1px solid var(--line); }
.bubble pre code { padding:0; background:none; }
.bubble blockquote { margin:12px 0; padding:10px 14px; border-left:3px solid var(--purple); background:#a78bfa0d; color:var(--dim); }
.table-scroll { max-width:100%; overflow-x:auto; margin:14px 0; border:1px solid var(--line); border-radius:8px; }
.bubble table { border-collapse:collapse; width:100%; min-width:680px; font-size:13px; }
.bubble th,.bubble td { border:1px solid var(--line); padding:10px 12px; text-align:left; vertical-align:top; }
.bubble th:first-child,.bubble td:first-child { min-width:120px; }
.bubble th:nth-child(2),.bubble td:nth-child(2) { min-width:90px; }
.bubble th:nth-child(3),.bubble td:nth-child(3),.bubble th:nth-child(4),.bubble td:nth-child(4) { min-width:220px; }
.bubble th { background:#22d3ee10; color:var(--cyan); }
.copy-feedback { margin:12px 0; color:var(--dim); font-size:13px; }
.foot { margin-top:28px; color:var(--muted); text-align:center; font-size:12px; }
@media (max-width:640px) {
  .wrap { padding:14px 14px max(28px,env(safe-area-inset-bottom)); }
  .grid,.stages { grid-template-columns:minmax(0,1fr); }
  .card { padding:18px; }
  .head { gap:10px; }
  h1 { font-size:21px; }
  .heading { flex-basis:200px; }
  #status { margin:3px 0 0; }
  .actions { align-items:stretch; }
  .actions button { flex:1 1 180px; }
  .result-head .ghost { width:100%; }
}
@media (prefers-reduced-motion:reduce) {
  html { scroll-behavior:auto; }
  .stage.is-running,.stage.is-running .step-no,.pipeline-feedback.is-busy .pipeline-spinner { animation:none; }
}
