/* 悬浮入口按钮 */
#a11y-toggle-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 999999;
  width: 50px;
  height: 50px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: #2563eb;
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.35);
}

/* 主面板 */
#a11y-panel {
  position: fixed;
  right: 16px;
  bottom: 80px;
  width: 360px;
  max-height: 80vh;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.45);
  display: none;
  flex-direction: column;
  z-index: 999998;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#a11y-panel.a11y-panel-open {
  display: flex;
}

.a11y-panel-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 16px 16px 0 0;
}

.a11y-panel-header-title {
  font-size: 15px;
  font-weight: 600;
}

.a11y-panel-header-shortcut {
  font-size: 11px;
  opacity: 0.9;
}

#a11y-close-btn {
  border: none;
  background: transparent;
  color: #e5e7eb;
  cursor: pointer;
  font-size: 18px;
}

.a11y-panel-body {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

/* 功能按钮通用样式 */
.a11y-btn {
  font-size: 12px;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
}

.a11y-btn span {
  display: block;
}

.a11y-btn-label {
  font-weight: 500;
}

.a11y-btn-desc {
  font-size: 10px;
  color: #6b7280;
}

.a11y-btn-active {
  border-color: #2563eb;
  background: #eff6ff;
}

/* 下方的行控制（字体大小、行距等） */
.a11y-control-row {
  grid-column: span 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  font-size: 12px;
}

.a11y-control-row span {
  font-weight: 500;
}

.a11y-control-row .a11y-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.a11y-stepper button {
  border-radius: 999px;
  width: 22px;
  height: 22px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.a11y-stepper-value {
  min-width: 36px;
  text-align: center;
  font-size: 11px;
  color: #6b7280;
}

/* Reset 一行独占 */
#a11y-reset {
  grid-column: span 3;
  margin-top: 4px;
  width: 100%;
  padding: 8px 0;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
}

/* ========== Reading Mask ========== */
#a11y-reading-mask {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999997;
  background: linear-gradient(
    to bottom,
    rgba(15, 23, 42, 0.7) 0,
    rgba(15, 23, 42, 0.7) var(--mask-top),
    transparent var(--mask-top),
    transparent calc(var(--mask-top) + var(--mask-height)),
    rgba(15, 23, 42, 0.7) calc(var(--mask-top) + var(--mask-height)),
    rgba(15, 23, 42, 0.7) 100%
  );
}

/* ========== Text Magnifier ========== */
#a11y-text-magnifier {
  position: fixed;
  max-width: 320px;
  padding: 8px 10px;
  font-size: 18px;
  line-height: 1.4;
  background: #fefce8;
  border-radius: 10px;
  border: 1px solid #facc15;
  box-shadow: 0 3px 16px rgba(0, 0, 0, 0.3);
  z-index: 999999;
  pointer-events: none;
  color: #111827;
}

/* ========== 全局变量（字体/行距/字间距） ========== */
html {
  --a11y-font-scale: 1;
  --a11y-line-height: 1;
  --a11y-letter-spacing: 1;
}

body {
  font-size: calc(16px * var(--a11y-font-scale));
  line-height: calc(1.5 * var(--a11y-line-height));
  letter-spacing: calc(0em + (var(--a11y-letter-spacing) - 1) * 0.06em);
}

/* 高对比度 */
html.a11y-high-contrast {
  background-color: #000 !important;
  color: #fff !important;
}

html.a11y-high-contrast body,
html.a11y-high-contrast * {
  background-color: transparent !important;
  color: #fff !important;
  border-color: #9ca3af !important;
}

/* 暗色模式（比高对比度柔和一点） */
html.a11y-dark-mode {
  background-color: #020617;
  color: #e5e7eb;
}

html.a11y-dark-mode body {
  background-color: #020617;
  color: #e5e7eb;
}

/* 去色模式 */
html.a11y-desaturate {
  filter: grayscale(1);
}

/* 可读字体，比如统一无衬线 */
html.a11y-readable-font * {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif !important;
}

/* 链接高亮 */
html.a11y-highlight-links a {
  outline: 2px solid #f97316;
  background-color: rgba(251, 146, 60, 0.2);
}

/* 标题高亮 */
html.a11y-highlight-titles h1,
html.a11y-highlight-titles h2,
html.a11y-highlight-titles h3 {
  background-color: rgba(56, 189, 248, 0.25);
}

/* 隐藏图片 */
html.a11y-hide-images img {
  visibility: hidden !important;
}
