/* ============================================================
   base.css —— 重置、排版、滚动条、无障碍
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* 字号缩放：设置页「界面字号」小/标准/大 = 0.85/1.0/1.15 */
  font-size: calc(16px * var(--font-scale));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--c-text);
  background: var(--c-window);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
  /* 桌面应用观感：禁掉浏览器级文本选择（可编辑区单独放开） */
  user-select: none;
  cursor: default;
}

input,
textarea,
[contenteditable] {
  user-select: text;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  padding: 0;
  cursor: default;
}

a {
  color: var(--c-accent);
  text-decoration: none;
}

img,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--c-separator);
  margin: var(--sp-sm) 0;
}

/* ── 滚动条：macOS overlay 风格，静止时几乎不可见 ── */
::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
  transition: background var(--d-hover) var(--ease-apple);
}

*:hover > ::-webkit-scrollbar-thumb,
::-webkit-scrollbar-thumb:hover {
  background: var(--c-scroll-thumb);
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:active {
  background: var(--c-scroll-thumb-hover);
  background-clip: content-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--c-scroll-thumb) transparent;
}

/* ── 焦点可见性：键盘可达，鼠标点击不显示焦点环 ── */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ── 文本工具类 ── */
.t-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--c-text);
}

.t-sub {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--c-text);
}

.t-body {
  font-size: var(--fs-base);
  color: var(--c-text);
}

.t-hint {
  font-size: var(--fs-xs);
  color: var(--c-text-3);
}

.t-muted {
  font-size: var(--fs-xs);
  color: var(--c-text-3);
}

.t-mono {
  font-family: var(--font-mono);
}

.t-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.t-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.t-center { text-align: center; }
.t-right { text-align: right; }
.t-nowrap { white-space: nowrap; }

.u-hidden { display: none !important; }
.u-invisible { visibility: hidden !important; }
.u-flex { display: flex; }
.u-flex-col { display: flex; flex-direction: column; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-gap-xs { gap: var(--sp-xs); }
.u-gap-sm { gap: var(--sp-sm); }
.u-gap-md { gap: var(--sp-md); }
.u-grow { flex: 1 1 auto; min-width: 0; }
.u-scroll-y { overflow-y: auto; overflow-x: hidden; }

/* ── 减弱动态效果（设置 key: reduce_motion） ── */
[data-reduce-motion="1"] *,
[data-reduce-motion="1"] *::before,
[data-reduce-motion="1"] *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
  scroll-behavior: auto !important;
}

@media (prefers-reduced-motion: reduce) {
  .mark-ring,
  .mark-icon,
  .breathing {
    animation: none !important;
  }
}

/* ── 拖放高亮 ── */
.drop-active {
  border-color: var(--c-accent) !important;
  background: var(--c-accent-subtle) !important;
  transition: background var(--d-micro) var(--ease-apple),
              border-color var(--d-micro) var(--ease-apple);
}

/* ── 全局拖拽遮罩：阻止浏览器默认"打开文件"行为 ── */
#drop-veil {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#drop-veil.on {
  display: flex;
}

#drop-veil .veil-box {
  padding: var(--sp-xl) var(--sp-xxxl);
  border-radius: var(--r-sheet);
  border: 2px dashed var(--c-accent);
  background: var(--m-thick);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--sh-raised);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--c-accent);
  animation: veil-in var(--d-modal-in) var(--ease-decelerate);
}

@keyframes veil-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}
