:root {
  --bg: #0b1220;
  --panel: #121b2e;
  --panel-2: #172238;
  --line: #24324d;
  --text: #e6ecf7;
  --muted: #8d9bb5;
  --accent: #4f8cff;
  --accent-strong: #2f6fe0;   /* 实心按钮底色：白字对比度 4.7:1（--accent 只有 3.2:1） */
  --field-line: #5b6d92;      /* 输入框、次要按钮边框：在面板上 ≥3:1 */
  --ok: #2fbf71;
  --warn: #f2a93b;
  --bad: #ef5d5d;
  --radius: 14px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
/* 背景光晕放在固定的伪元素上：background-attachment: fixed 会让每次滚动都整屏重绘 */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2b52 0%, var(--bg) 55%); }
a { color: var(--accent); }
:focus-visible { outline: 2px solid #6ea0ff; outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: 1; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px; border-bottom: 1px solid var(--line); background: #0b1220f2; position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; letter-spacing: .3px; }
.brand.center { justify-content: center; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #4f8cff, #7a5cff); display: grid; place-items: center; font-size: 14px; }
.user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
/* 页头里的文字链接做成轻量按钮样式，不用原生下划线 */
.user a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap;
  display: inline-flex; align-items: center; }
.user a:hover { color: var(--text); background: var(--panel-2); }

button, .button {
  appearance: none; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; font: inherit; font-size: 14px;
  cursor: pointer; background: var(--accent-strong); color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; transition: background-color .15s, border-color .15s, filter .15s;
}
button:hover:not(:disabled), .button:hover { filter: brightness(1.12); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost, .button.ghost { background: transparent; border-color: var(--field-line); color: var(--text); }
button.ghost:hover:not(:disabled), .button.ghost:hover { border-color: var(--accent); filter: none; }
button.danger { background: transparent; border-color: #7a3a45; color: #ff8d8d; }
button.danger:hover:not(:disabled) { background: #2a0f14; filter: none; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px 30px 26px; text-align: center; box-shadow: 0 20px 60px #0008; }
.login-card h1 { margin: 6px 0 4px; font-size: 22px; }
.login-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
/* 朗空量子护盾身份验证器 App 图标 + 说明 */
.app-hint { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 22px; text-align: left; }
.app-hint img { width: 40px; height: auto; flex: none; }
.app-hint .sub, .app-hint .desc { margin: 0; }
.app-hint.left { justify-content: flex-start; margin: 0 0 14px; }
.qr-box { position: relative; width: 248px; height: 248px; margin: 0 auto 16px; border-radius: 14px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.qr-box svg { width: 232px; height: 232px; }
.qr-mask { position: absolute; inset: 0; background: #0b1220e0; color: var(--text); display: grid; place-items: center; text-align: center; padding: 20px; font-size: 15px; }
.qr-mask .big { font-size: 34px; display: block; margin-bottom: 8px; }
.status { min-height: 22px; font-size: 15px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }
.status.warn { color: var(--warn); }
.countdown { font-size: 13px; color: var(--muted); margin-top: 4px; }
.login-card footer { margin-top: 22px; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* demo 列表 */
main { max-width: 1120px; margin: 0 auto; padding: 28px; }
.intro h2 { margin: 0 0 6px; font-size: 22px; }
.intro p { margin: 0 0 22px; color: var(--muted); }
/* 首页专题入口（格密码挑战） */
.feature {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; align-items: center; margin-bottom: 22px; padding: 18px 22px;
  border-radius: var(--radius); text-decoration: none; color: var(--text);
  background: linear-gradient(120deg, #1a2d5e, #2a1d5c); border: 1px solid #3d4b8a; transition: border-color .15s, transform .15s;
}
.feature:hover { border-color: var(--accent); transform: translateY(-1px); }
.feature-tag { grid-column: 1; font-size: 12px; color: #b9c7ff; letter-spacing: .5px; }
.feature-title { grid-column: 1; font-size: 18px; font-weight: 700; }
.feature-desc { grid-column: 1; font-size: 14px; color: #c3cde0; }
.feature-go { grid-column: 2; grid-row: 1 / span 3; padding: 9px 16px; border-radius: 10px; background: var(--accent-strong); color: #fff; font-size: 14px; white-space: nowrap; }
@media (max-width: 600px) { .feature { grid-template-columns: 1fr; } .feature-go { grid-column: 1; grid-row: auto; justify-self: start; margin-top: 8px; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.card h3 { margin: 0; font-size: 17px; }
.card .desc { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); white-space: nowrap; flex: none; }
/* 运行状态前加一个圆点，启动中闪烁，远处也能一眼看出 */
.badge.running::before, .badge.starting::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.starting::before { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.card.is-running { border-color: #1f5c3d; }
.badge.running { color: var(--ok); border-color: #1f5c3d; background: #0f2a1d; }
.badge.starting, .badge.stopping { color: var(--warn); border-color: #5c4a1f; background: #2a220f; }
.badge.failed { color: var(--bad); border-color: #5c1f1f; background: #2a0f0f; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* 卡片里的按钮行沉到底部，三张卡的按钮落在同一水平线上 */
.card > .actions { margin-top: auto; }
.guide { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
details.log-box summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.log-box pre.log { margin-top: 8px; }
.alert { border-radius: 10px; padding: 9px 12px; font-size: 13px; line-height: 1.6; }
.alert.warn { background: #2a220f; border: 1px solid #5c4a1f; color: #f5cf8a; }
.alert.bad { background: #2a0f0f; border: 1px solid #5c1f1f; color: #ffb3b3; }
pre.log { margin: 0; max-height: 160px; overflow: auto; background: #070b14; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; color: #b9c4da; white-space: pre-wrap; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 420px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-size: 14px; box-shadow: 0 10px 30px #0008; }

/* 后台管理 */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab { background: transparent; border-color: var(--line); color: var(--muted); }
.tab.active { background: var(--panel-2); color: var(--text); border-color: var(--accent); }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-row input[type=text] { flex: 1 1 180px; width: auto; }
.form-row input[type=date], select {
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--field-line); background: #0a1120; color: var(--text); font: inherit;
}
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.table td[colspan] { text-align: center; padding: 28px 10px; color: var(--muted); }
table.table th, table.table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.table th { color: var(--muted); font-weight: 500; white-space: nowrap; }
table.table td.ua { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small-btn { padding: 5px 10px; font-size: 13px; margin-right: 6px; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
/* 后台页卡片之间的间距；演示列表（.grid）由 gap 控制，不能再加，否则第二、三张卡会比第一张低 */
main > section:not(.grid) > .card + .card { margin-top: 18px; }
.card > h3:not(:first-child) { margin-top: 10px; }

/* 左右对照视图 */
body.view-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
body.dragging { cursor: col-resize; user-select: none; }
body.dragging iframe { pointer-events: none; }
.view-top { position: static; padding: 10px 18px; }
.view-top .brand { gap: 10px; }
.split { flex: 1; display: flex; min-height: 0; max-width: none; margin: 0; padding: 0; }
.pane { display: flex; flex-direction: column; min-width: 0; flex: 1 1 50%; }
.pane-bar {
  display: flex; justify-content: space-between; align-items: center; padding: 6px 14px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600;
}
.pane-bar a { font-weight: 400; font-size: 12px; }
.pane-body { position: relative; flex: 1; min-height: 0; }
/* 按 --zoom 缩放 iframe：先按 1/zoom 放大布局尺寸，再整体缩小，页面按更宽的视口排版，文字随之变小 */
.split { --zoom: 0.75; }
.pane-body { overflow: hidden; }
.pane-body iframe {
  position: absolute; left: 0; top: 0; border: 0; background: #0b1220;
  width: calc(100% / var(--zoom)); height: calc(100% / var(--zoom)); transform: scale(var(--zoom)); transform-origin: 0 0;
}
.zoom { display: inline-flex; align-items: center; gap: 2px; }
.zoom .small-btn { margin-right: 0; min-width: 34px; justify-content: center; }
#zoomReset { min-width: 56px; }
.pane-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px;
  background: var(--bg); color: var(--muted); font-size: 15px;
}
/* 分隔条加一道中间握把，投影上也看得出可以拖动 */
.splitter { flex: 0 0 8px; cursor: col-resize; background: #3a4a6b linear-gradient(var(--muted), var(--muted)) center / 2px 32px no-repeat; }
.splitter:hover, .splitter:focus-visible { background-color: var(--accent); }
@media (max-width: 900px) { .split { flex-direction: column; } .splitter { display: none; } }

/* setup */
.setup { max-width: 720px; }
.setup .card { margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
code.block { display: block; background: #070b14; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 13px; word-break: break-all; }
input[type=password], input[type=text] { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--field-line); background: #0a1120; color: var(--text); font: inherit; }

/* 手机：页头折成两行、正文加宽、卡片单列 */
@media (max-width: 600px) {
  header.top { flex-wrap: wrap; padding: 12px 16px; gap: 8px; }
  .brand span { white-space: nowrap; }
  .user { flex-wrap: wrap; gap: 6px 10px; font-size: 13px; }
  main { padding: 18px 16px; }
  .grid { grid-template-columns: 1fr; }
  .login-card { padding: 26px 20px 22px; }
  .kv { grid-template-columns: 100px 1fr; }
}
/* 触屏：按钮和链接至少 44px 高 */
@media (pointer: coarse) {
  button, .button, .small-btn, .user a { min-height: 44px; }
}
/* 1920 投影：三列铺满，正文放大 */
@media (min-width: 1600px) {
  main { max-width: 1440px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .intro h2 { font-size: 28px; }
  .intro p { font-size: 16px; }
  .card h3 { font-size: 20px; }
  .card .desc { font-size: 16px; }
  .guide { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .feature:hover { transform: none; }
}
