/* 闸门样式：颜色一律取 --tk-*（由 js/gate-theme.js 推导），不写死任何品牌色 */
:root {
  --tk-bg: #ffffff;
  --tk-fg: #1f2328;
  --tk-accent: #ff6b6b;
  --tk-accent-2: #3498db;
  --tk-muted: #6b7280;
  --tk-dim: #9ca3af;
  --tk-line: #e5e7eb;
  --tk-card: #ffffff;
  --tk-font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --tk-warn: #f59e0b;
}

/* 加载期与拦截期：正文一律隐藏（只留闸门卡片） */
html[data-gate="pending"] body > *:not(#tk-gate):not(script):not(style):not(link):not(template),
html[data-gate="block"] body > *:not(#tk-gate):not(script):not(style):not(link):not(template) {
  visibility: hidden !important;
}

html[data-gate="pass"] #tk-gate {
  display: none !important;
}

html[data-gate="pass"] body > .container {
  animation: tk-page-in .38s ease both;
}

@keyframes tk-page-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@keyframes tk-card-in {
  from { opacity: 0; transform: translateY(8px) scale(.995); }
  to { opacity: 1; transform: none; }
}

@keyframes tk-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

@keyframes tk-bar {
  from { background-position: 0 0; }
  to { background-position: 40px 0; }
}

@keyframes tk-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}

#tk-gate {
  position: fixed;
  inset: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: var(--tk-bg);
  color: var(--tk-fg);
  font-family: var(--tk-font);
  -webkit-font-smoothing: antialiased;
  transition: opacity .35s ease, visibility .35s ease;
}

#tk-gate[data-state="out"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.tk-gate-card {
  width: 100%;
  max-width: 452px;
  background: var(--tk-card);
  color: var(--tk-fg);
  border: 1px solid var(--tk-line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .14), 0 2px 6px rgba(15, 23, 42, .06);
  padding: 26px 26px 20px;
  animation: tk-card-in .32s ease both;
}

#tk-gate[data-state="blocked"] .tk-gate-card.tk-shake,
.tk-gate-card.tk-shake { animation: tk-shake .4s ease; }

.tk-gate-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tk-muted);
  letter-spacing: .01em;
}

.tk-gate-brand img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  object-fit: contain;
  display: block;
}

#tk-gate-title {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -.01em;
}

#tk-gate-sub {
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--tk-muted);
}

.tk-gate-steps {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.tk-gate-steps li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--tk-muted);
  min-height: 22px;
}

.tk-gate-steps li i {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid var(--tk-line);
  flex: 0 0 auto;
  position: relative;
  transition: border-color .2s ease, background .2s ease;
}

.tk-gate-steps li[data-state="running"] i {
  border-color: var(--tk-accent);
  border-top-color: transparent;
  animation: tk-spin .7s linear infinite;
}

@keyframes tk-spin { to { transform: rotate(360deg); } }

.tk-gate-steps li[data-state="done"] i {
  border-color: var(--tk-accent);
  background: var(--tk-accent);
}

.tk-gate-steps li[data-state="done"] i::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid #fff;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}

.tk-gate-steps li[data-state="warn"] i {
  border-color: var(--tk-warn);
  background: var(--tk-warn);
}

.tk-gate-steps li[data-state="done"],
.tk-gate-steps li[data-state="warn"] { color: var(--tk-fg); }

.tk-gate-steps li em {
  margin-inline-start: auto;
  font-style: normal;
  font-size: 11.5px;
  color: var(--tk-dim);
  white-space: nowrap;
}

.tk-gate-steps li[data-state="running"] em { color: var(--tk-accent); animation: tk-pulse 1.2s ease-in-out infinite; }

.tk-gate-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--tk-line);
  overflow: hidden;
  margin-bottom: 8px;
}

#tk-gate-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--tk-accent), var(--tk-accent-2));
  background-size: 40px 40px;
  transition: width .18s linear;
}

.tk-gate-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--tk-dim);
  font-variant-numeric: tabular-nums;
  margin-bottom: 14px;
}

.tk-gate-foot {
  margin: 12px 0 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--tk-dim);
  border-top: 1px dashed var(--tk-line);
  padding-top: 10px;
}

.tk-gate-block {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--tk-line);
}

.tk-gate-block[hidden] { display: none; }

.tk-gate-block h3 {
  margin: 0 0 6px;
  font-size: 15.5px;
  color: var(--tk-accent);
  font-weight: 700;
}

.tk-gate-block p {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--tk-muted);
}

.tk-gate-btn {
  appearance: none;
  border: 0;
  border-radius: 9px;
  background: var(--tk-accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  cursor: pointer;
  margin-top: 4px;
  transition: filter .2s ease, transform .2s ease;
}

.tk-gate-btn:hover { filter: brightness(1.05); }
.tk-gate-btn:active { transform: scale(.98); }

html[data-gate-scheme="dark"] #tk-gate {
  background: var(--tk-bg);
}

html[data-gate-scheme="dark"] .tk-gate-card {
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
}

#tk-gate[dir="rtl"] .tk-gate-steps li em { margin-inline-start: auto; margin-inline-end: 0; }

@media (max-width: 480px) {
  #tk-gate { padding: 12px; }
  .tk-gate-card { padding: 20px 18px 16px; border-radius: 16px; }
  #tk-gate-title { font-size: 18px; }
  #tk-gate-sub { font-size: 13px; }
  .tk-gate-steps li { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .tk-gate-card, #tk-gate, html[data-gate="pass"] #tk-gate {
  display: none !important;
}

html[data-gate="pass"] body > .container { animation: none !important; transition: none !important; }
}
