:root {
  color-scheme: light;
  --ink: #16233a;
  --blue: #2855ff;
  --paper: #f4f7fb;
  --white: #ffffff;
  --mist: #dce4ee;
  --muted: #667389;
  --signal: #ff5c47;
  --success: #16895a;
  --shadow: 0 24px 70px rgba(22, 35, 58, 0.11);
  --radius: 20px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  left: 20px;
  top: -80px;
  z-index: 20;
  padding: 12px 16px;
  color: #fff;
  background: var(--blue);
  border-radius: 10px;
}

.skip-link:focus { top: 20px; }

.route-rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 8px;
  background: var(--blue);
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}

.route-rail i { width: 8px; height: 18px; background: var(--signal); }

.masthead {
  min-height: 86px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 18px clamp(24px, 5vw, 76px);
  border-bottom: 1px solid var(--mist);
  background: rgba(244, 247, 251, 0.92);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 9;
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; width: max-content; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50% 50% 50% 12px; color: #fff; background: var(--ink); font-family: "Songti SC", serif; font-size: 23px; }
.brand b { display: block; font-family: "Songti SC", serif; font-size: 22px; line-height: 1; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font: 700 9px/1 ui-monospace, Consolas, monospace; letter-spacing: .16em; }

.service-state { justify-self: center; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #aab4c3; box-shadow: 0 0 0 4px #e5eaf1; }
.status-dot.ready { background: var(--success); box-shadow: 0 0 0 4px #d9f3e7; }
.status-dot.error { background: var(--signal); box-shadow: 0 0 0 4px #ffe5e0; }

.token-field { justify-self: end; display: flex; align-items: center; border: 1px solid var(--mist); background: #fff; border-radius: 11px; overflow: hidden; }
.token-field > span { padding-left: 13px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.token-field input { width: 140px; border: 0; outline: 0; padding: 10px; background: transparent; }
.token-field button { align-self: stretch; border: 0; border-left: 1px solid var(--mist); background: #fff; padding: 0 13px; cursor: pointer; font-size: 12px; font-weight: 700; }
.token-field button:hover { background: #eef2ff; color: var(--blue); }

main { width: min(1500px, calc(100% - 48px)); margin: 0 auto; padding-bottom: 90px; }

.intro {
  min-height: 330px;
  display: grid;
  grid-template-columns: 1.4fr .6fr;
  gap: 8vw;
  align-items: end;
  padding: 70px 0 52px;
}

.kicker, .step { color: var(--blue); font: 800 11px/1.4 ui-monospace, Consolas, monospace; letter-spacing: .18em; text-transform: uppercase; }
.intro h1 { margin: 8px 0 0; font-family: "Songti SC", "STSong", serif; font-size: clamp(44px, 6vw, 88px); line-height: 1.02; letter-spacing: -.055em; font-weight: 700; }
.intro h1 em { color: var(--blue); font-style: normal; }
.intro-copy { margin: 0 0 9px; max-width: 440px; color: var(--muted); font-size: 16px; line-height: 1.9; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(390px, .96fr); border: 1px solid var(--mist); border-radius: 26px; overflow: hidden; box-shadow: var(--shadow); background: var(--white); }
.editor, .preview-panel { padding: clamp(24px, 4vw, 54px); }
.editor { display: grid; grid-template-columns: 1fr; gap: 24px; }
.preview-panel { background: var(--ink); color: #fff; position: relative; overflow: hidden; }
.preview-panel::before { content: ""; position: absolute; width: 340px; height: 340px; right: -170px; top: -160px; border: 56px solid rgba(40, 85, 255, .28); border-radius: 50%; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-head h2 { margin: 5px 0 0; font-family: "Songti SC", serif; font-size: 30px; letter-spacing: -.03em; }
.section-head.inverse h2 { color: #fff; }
.text-button { border: 0; background: transparent; color: var(--blue); cursor: pointer; text-decoration: underline; }

.field { display: grid; gap: 9px; }
.field > span { display: flex; justify-content: space-between; font-size: 13px; font-weight: 800; }
.field > span small, .field > small { color: var(--muted); font-size: 11px; font-weight: 500; }
.field input, .field textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 12px; padding: 13px 14px; outline: 0; color: var(--ink); background: #fff; transition: border-color .16s, box-shadow .16s; }
.field textarea { resize: vertical; line-height: 1.65; }
.field input:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(40, 85, 255, .1); }
.field input:invalid:not(:placeholder-shown) { border-color: var(--signal); }
.field-pair { display: grid; grid-template-columns: .7fr 1.3fr; gap: 18px; }
.input-prefix { display: flex; align-items: center; border: 1px solid #cbd5e1; border-radius: 12px; overflow: hidden; background: #f3f6fa; }
.input-prefix:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(40, 85, 255, .1); }
.input-prefix i { padding-left: 13px; color: var(--muted); font: 600 13px/1 ui-monospace, Consolas, monospace; font-style: normal; }
.input-prefix input { border: 0; border-radius: 0; box-shadow: none !important; background: transparent; padding-left: 2px; font-family: ui-monospace, Consolas, monospace; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 17px 18px; background: #f4f7fb; border-radius: 14px; cursor: pointer; }
.switch-row span { display: grid; gap: 5px; }
.switch-row b { font-size: 13px; }
.switch-row small { color: var(--muted); line-height: 1.5; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { width: 48px; height: 28px; padding: 3px; border-radius: 99px; background: #b9c3d1; transition: background .2s; flex: 0 0 auto; }
.switch-row i::after { content: ""; display: block; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px #16233a33; transition: transform .2s; }
.switch-row input:checked + i { background: var(--blue); }
.switch-row input:checked + i::after { transform: translateX(20px); }
.switch-row input:focus-visible + i { outline: 3px solid rgba(40, 85, 255, .26); outline-offset: 3px; }

.form-actions { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 18px; }
.form-actions p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.primary-button { display: inline-flex; align-items: center; gap: 42px; border: 0; padding: 14px 18px; color: #fff; background: var(--blue); border-radius: 12px; cursor: pointer; font-weight: 800; box-shadow: 0 9px 22px rgba(40, 85, 255, .22); }
.primary-button:hover { background: #1743e6; transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button b { font-size: 18px; }

.live-pill { border: 1px solid rgba(255, 255, 255, .22); border-radius: 99px; padding: 6px 9px; font-size: 10px; color: #bec8d8; }
.chat-canvas { position: relative; z-index: 1; margin-top: 38px; padding: 24px 18px 38px; min-height: 330px; border-radius: 18px; background: #eef0f3; color: var(--ink); }
.chat-canvas time { display: block; text-align: center; color: #9da5b1; font-size: 10px; margin-bottom: 28px; }
.message-row { display: flex; align-items: flex-start; gap: 11px; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; color: #fff; background: var(--blue); font-family: "Songti SC", serif; font-weight: 800; flex: 0 0 auto; }
.wechat-card { width: min(100%, 350px); min-height: 128px; display: grid; grid-template-columns: 1fr 76px; gap: 13px; padding: 15px; border-radius: 4px 14px 14px 14px; background: #fff; box-shadow: 0 1px 1px #16233a13; }
.wechat-card h3 { margin: 0 0 8px; font-size: 16px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wechat-card p { margin: 0; color: #7b838f; font-size: 11px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wechat-card img { width: 76px; height: 76px; object-fit: cover; border-radius: 5px; background: #e1e6ed; }
.path-ticket { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 18px; padding: 17px; border: 1px dashed rgba(255,255,255,.32); border-radius: 14px; }
.path-ticket div { min-width: 0; }
.path-ticket span { display: block; color: #9ba9bc; font-size: 10px; margin-bottom: 7px; }
.path-ticket code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font: 700 12px/1.2 ui-monospace, Consolas, monospace; }
.path-ticket i { color: var(--signal); font-style: normal; font-size: 20px; }
.preview-note { color: #9ba9bc; font-size: 11px; line-height: 1.65; margin: 16px 0 0; }

.library, .integration { margin-top: 36px; border: 1px solid var(--mist); border-radius: var(--radius); background: var(--white); padding: clamp(24px, 4vw, 44px); }
.count-badge { color: var(--muted); font: 700 11px/1 ui-monospace, Consolas, monospace; }
.card-list { display: grid; gap: 0; margin-top: 26px; border-top: 1px solid var(--mist); }
.route-card { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(210px, 1fr) auto; gap: 24px; align-items: center; padding: 21px 0; border-bottom: 1px solid var(--mist); }
.route-card.off { opacity: .57; }
.route-card h3 { margin: 0 0 7px; font-size: 15px; }
.route-card p { margin: 0; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-meta { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; }
.route-meta code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--blue); font: 700 11px/1.3 ui-monospace, Consolas, monospace; }
.route-stat { display: grid; gap: 3px; text-align: right; }
.route-stat b { font: 800 14px/1 ui-monospace, Consolas, monospace; }
.route-stat span { color: var(--muted); font-size: 9px; }
.card-actions { display: flex; gap: 7px; }
.card-actions button { border: 1px solid var(--mist); background: #fff; border-radius: 9px; padding: 8px 10px; cursor: pointer; font-size: 11px; font-weight: 700; }
.card-actions button:hover { border-color: var(--blue); color: var(--blue); }
.card-actions .danger:hover { border-color: var(--signal); color: var(--signal); }
.empty-state { margin-top: 24px; padding: 42px; text-align: center; border: 1px dashed #b9c4d3; border-radius: 15px; }
.empty-state b, .empty-state span { display: block; }
.empty-state span { color: var(--muted); margin-top: 8px; }

.integration { display: grid; grid-template-columns: .35fr 1.65fr; gap: 50px; background: #eaf0f7; }
.integration h2 { font-family: "Songti SC", serif; font-size: 30px; margin: 5px 0; }
.integration-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.integration-grid article { position: relative; padding: 24px; background: #fff; border-radius: 15px; }
.integration-index { position: absolute; right: 20px; top: 18px; color: #c3ccda; font: 800 30px/1 ui-monospace, Consolas, monospace; }
.integration-grid h3 { margin: 0 0 10px; font-size: 15px; }
.integration-grid p { min-height: 64px; margin: 0 0 16px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.integration-grid strong { color: var(--muted); font-size: 11px; }
.integration-grid .good { color: var(--success); }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 16px; background: var(--ink); color: #fff; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #9f2f23; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(10, 20, 38, .68);
  backdrop-filter: blur(12px);
}

.auth-gate[hidden] { display: none !important; }

.auth-dialog {
  position: relative;
  width: min(100%, 440px);
  padding: 38px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 32px 100px rgba(7, 18, 38, .34);
}

.auth-dialog::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 7px;
  background: repeating-linear-gradient(90deg, var(--blue) 0 46px, transparent 46px 54px, var(--signal) 54px 64px, transparent 64px 72px);
}

.auth-seal { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 22px; border-radius: 50% 50% 50% 12px; color: #fff; background: var(--ink); font-family: "Songti SC", serif; font-size: 22px; }
.auth-dialog h2 { margin: 6px 0 12px; font-family: "Songti SC", serif; font-size: 34px; letter-spacing: -.04em; }
.auth-dialog > p:not(.kicker):not(.auth-error) { margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.75; }
.auth-input { display: grid; gap: 8px; }
.auth-input span { font-size: 12px; font-weight: 800; }
.auth-input input { width: 100%; border: 1px solid #cbd5e1; border-radius: 12px; padding: 13px 14px; outline: 0; }
.auth-input input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(40,85,255,.1); }
.remember-row { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; color: var(--muted); font-size: 12px; cursor: pointer; }
.remember-row input { accent-color: var(--blue); }
.auth-error { min-height: 20px; margin: 12px 0 4px; color: #a83226; font-size: 12px; }
.auth-submit { width: 100%; justify-content: space-between; }
.auth-dialog > small { display: block; margin-top: 13px; color: #8a95a6; font-size: 10px; text-align: center; }

button:focus-visible, a:focus-visible { outline: 3px solid rgba(40, 85, 255, .3); outline-offset: 3px; }

@media (max-width: 980px) {
  .masthead { grid-template-columns: 1fr auto; }
  .service-state { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { min-height: 600px; }
  .route-card { grid-template-columns: 1fr; gap: 13px; }
  .route-meta { max-width: 460px; }
  .card-actions { justify-self: start; }
  .integration { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 680px) {
  .route-rail { width: 5px; }
  .masthead { position: static; grid-template-columns: 1fr; gap: 12px; padding: 15px 20px 15px 24px; }
  .brand small { display: none; }
  .token-field { justify-self: stretch; }
  .token-field > span { display: none; }
  .token-field input { width: auto; min-width: 0; flex: 1; }
  main { width: min(100% - 30px, 1500px); }
  .intro { min-height: 300px; grid-template-columns: 1fr; gap: 24px; align-content: center; padding: 46px 0; }
  .intro h1 { font-size: clamp(38px, 12.5vw, 54px); letter-spacing: -.065em; }
  .intro-copy { font-size: 14px; }
  .workspace { border-radius: 18px; }
  .editor, .preview-panel { padding: 25px 20px; }
  .field-pair, .form-actions, .integration-grid { grid-template-columns: 1fr; }
  .primary-button { justify-content: space-between; }
  .preview-panel { min-height: auto; }
  .chat-canvas { min-height: 290px; padding-inline: 12px; }
  .wechat-card { grid-template-columns: 1fr 66px; padding: 12px; }
  .wechat-card img { width: 66px; height: 66px; }
  .path-ticket { grid-template-columns: 1fr; }
  .path-ticket i { transform: rotate(90deg); }
  .library, .integration { padding: 25px 20px; }
  .route-meta { grid-template-columns: 1fr auto auto; gap: 10px; }
  .card-actions { flex-wrap: wrap; }
  .auth-dialog { padding: 32px 24px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
