/* =========================================================
   文章代码块 · macOS 窗口样式
   颜色全部取自当前主题变量，浅色/深色/晨光主题自动跟随
   ========================================================= */

.code-window {
  --code-window-bg: var(--surface-2);
  --code-window-bar: var(--surface-3);
  --code-window-border: var(--border);
  --code-window-ink: var(--ink);
  --code-window-muted: var(--muted);
  --code-window-faint: var(--faint);
  --code-window-accent: var(--accent);
  --code-window-accent-deep: var(--accent-deep);
  --code-window-green: var(--green);
  --code-window-gold: var(--gold);
  display: flex;
  flex-direction: column;
  max-height: 640px;
  margin: 1.6em 0;
  overflow: hidden;
  border: 1px solid var(--code-window-border);
  border-radius: 14px;
  background: var(--code-window-bg);
  box-shadow: var(--shadow-sm);
}

.code-window__bar {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 39px;
  padding: 0 14px;
  border-bottom: 1px solid var(--code-window-border);
  background: var(--code-window-bar);
}

.code-window__dots {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
}

.code-window__dots i {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .18);
}

.code-window__dots i:nth-child(1) { background: #ff5f57; }
.code-window__dots i:nth-child(2) { background: #febc2e; }
.code-window__dots i:nth-child(3) { background: #28c840; }

[data-theme="dark"] .code-window__dots i { filter: brightness(.86); }

.code-window__title {
  position: absolute;
  left: 50%;
  max-width: 62%;
  overflow: hidden;
  color: var(--code-window-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: .01em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.code-window__copy {
  flex: 0 0 auto;
  min-width: 44px;
  height: 24px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--code-window-muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}

.code-window__copy:hover,
.code-window__copy:focus-visible {
  border-color: var(--code-window-border);
  background: var(--surface);
  color: var(--code-window-accent);
  outline: 0;
}

.code-window__copy.is-copied { color: var(--code-window-green); }
.code-window__copy.is-failed { color: var(--code-window-accent); }

.code-window pre {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 18px 18px 18px 3.8em;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--code-window-ink);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.8;
  white-space: pre;
  tab-size: 4;
  overflow: auto;
  box-shadow: none;
}

.code-window pre code {
  display: block;
  min-width: max-content;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
}

/* 行号列：插件默认 top:0 已与代码首行对齐 */
.code-window .line-numbers-rows {
  top: 0;
  border-right: 1px solid var(--code-window-border);
  color: var(--code-window-faint);
  font-family: var(--font-mono);
  font-size: inherit;
  line-height: inherit;
}

.code-window .line-numbers-rows > span:before {
  color: var(--code-window-faint);
  padding-right: .9em;
}

/* ---------- Prism token colors ---------- */
.code-window .token.comment,
.code-window .token.prolog,
.code-window .token.doctype,
.code-window .token.cdata {
  color: var(--code-window-muted);
  font-style: italic;
}

.code-window .token.punctuation { color: var(--code-window-muted); }
.code-window .token.operator { color: var(--code-window-muted); }

.code-window .token.keyword,
.code-window .token.atrule,
.code-window .token.selector {
  color: var(--code-window-accent-deep);
  font-weight: 600;
}

.code-window .token.string,
.code-window .token.char,
.code-window .token.attr-value,
.code-window .token.inserted {
  color: var(--code-window-green);
}

.code-window .token.function,
.code-window .token.class-name,
.code-window .token.builtin {
  color: var(--code-window-accent);
}

.code-window .token.number,
.code-window .token.boolean,
.code-window .token.constant,
.code-window .token.symbol,
.code-window .token.important,
.code-window .token.deleted {
  color: var(--code-window-gold);
}

.code-window .token.tag,
.code-window .token.property,
.code-window .token.attr-name,
.code-window .token.namespace,
.code-window .token.entity {
  color: var(--code-window-accent-deep);
}

.code-window .token.variable,
.code-window .token.regex,
.code-window .token.url,
.code-window .token.url-contents {
  color: var(--code-window-green);
}

.code-window .token.bold { font-weight: 700; }
.code-window .token.italic { font-style: italic; }

@media (max-width: 680px) {
  .code-window {
    max-height: 256px;
  }

  .code-window__bar {
    min-height: 36px;
    padding: 0 11px;
  }

  .code-window__title { max-width: 52%; font-size: 11px; }
  .code-window__copy { min-width: 40px; padding: 0 6px; }

  .code-window pre {
    padding: 15px 15px 15px 3.4em;
    font-size: 12.5px;
  }

  .code-window .line-numbers-rows { top: 0; }
}
