:root {
  --ribbon-bg: oklch(0.955 0.012 264);
  --ribbon-card-bg: oklch(1 0 0);
  --editor-workspace-bg: oklch(0.965 0.004 264);
  --editor-surface-bg: oklch(1 0 0);
  --toolbar-slot-stroke: oklch(0.42 0 0 / 0.78);
}

.dark {
  --ribbon-bg: oklch(0.24 0.012 264);
  --ribbon-card-bg: oklch(0.19 0.006 264);
  --editor-workspace-bg: oklch(0.17 0.006 264);
  --editor-surface-bg: oklch(0.21 0.006 264);
  --toolbar-slot-stroke: oklch(0.8 0 0 / 0.72);
}

.math-ribbon {
  --ribbon-serif: "SimSun", "Songti SC", "NSimSun", "STSong", "Noto Serif SC", serif;
  background: var(--ribbon-bg);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.06),
    0 4px 12px rgba(0, 0, 0, 0.05);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: auto;
}

.math-ribbon__brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-right: 0.85rem;
  padding: 0.2rem 0.35rem 0.2rem 0.15rem;
  text-decoration: none;
  color: inherit;
}

.math-ribbon__brand:hover .math-ribbon__brand-name {
  opacity: 0.75;
}

.math-ribbon__brand-logo {
  width: 1.65rem;
  height: 1.65rem;
  flex-shrink: 0;
  border-radius: 0.35rem;
  object-fit: cover;
}

.math-ribbon__brand-name {
  font-size: 0.8125rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}

.math-ribbon__brand::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -0.5rem;
  width: 1px;
  height: 1.55rem;
  transform: translateY(-50%);
  background: color-mix(in oklch, var(--border, oklch(0.88 0.01 264)) 90%, transparent);
}

.dark .math-ribbon {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 14px rgba(0, 0, 0, 0.35);
}

.math-ribbon__tab-icon {
  display: flex;
  height: 1.75rem;
  width: 100%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.math-ribbon__tab-icon .katex {
  font-size: 1.2rem;
  line-height: 1;
  white-space: nowrap;
  color: var(--foreground);
}

.math-ribbon__tab-label {
  font-family: var(--ribbon-serif);
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.math-ribbon__group-label {
  font-family: var(--ribbon-serif);
  font-size: 11px;
  line-height: 1.2;
}

.math-ribbon__preview {
  display: flex;
  height: 100%;
  width: 100%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.math-ribbon__preview .katex {
  font-size: 1.05rem;
  line-height: 1;
  white-space: nowrap;
  color: var(--foreground);
}

.math-ribbon__preview--matrix .katex {
  font-size: 1.05rem;
}

/* 占位框：虚线边框，清晰可辨 */
.math-ribbon__preview .toolbar-slot,
.math-ribbon__preview .toolbar-slot-sm {
  display: inline-block !important;
  box-sizing: border-box;
  border: 1px dashed var(--toolbar-slot-stroke);
  outline: none;
  background: transparent !important;
  vertical-align: middle;
  overflow: hidden;
  line-height: 0;
  font-size: 0;
}

.math-ribbon__preview .toolbar-slot {
  width: 9px;
  height: 9px;
}

.math-ribbon__preview .toolbar-slot-sm {
  width: 6px;
  height: 6px;
}

.math-ribbon__preview--matrix .toolbar-slot {
  width: 7px;
  height: 7px;
}

/* 矩阵单元格间距收紧 */
.math-ribbon__preview--matrix .katex .mtable {
  margin: 0;
}

.math-ribbon__preview--matrix .katex .arraycolsep {
  width: 0.12em;
}

.math-ribbon__preview .toolbar-slot .rlap,
.math-ribbon__preview .toolbar-slot .fix,
.math-ribbon__preview .toolbar-slot-sm .rlap,
.math-ribbon__preview .toolbar-slot-sm .fix {
  display: none !important;
}

.math-ribbon__card {
  background: var(--ribbon-card-bg);
}

.editor-workspace {
  background: var(--editor-workspace-bg);
}

.editor-surface {
  background: var(--editor-surface-bg);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 4px 16px rgba(0, 0, 0, 0.06);
}

.dark .editor-surface {
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.25),
    0 4px 16px rgba(0, 0, 0, 0.35);
}
