/* ============================================================
   DualStar · 基础重置与排版
   ============================================================ */

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

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out);
  overscroll-behavior: none;
}

/* —— iOS / WebView 白底兜底（仅改背景色，不碰布局尺寸）——
   iOS WKWebView 默认白底；任何未被内容覆盖的区域（安全区、未铺满处）
   会露出 WebView 白底。html 是内容最底层，这里涂色即可遮住。 */
html {
  background: var(--bg);
}
html[data-theme="dark"] {
  background: #1a1a1a;
}

/* 根底色兜底：确保任何未被内容覆盖的区域（iOS 安全区 / 视觉视口之外的留白）
   都涂成应用背景色，杜绝 WebView 默认白底从底部（悬浮球够不到的安全区）露出。 */
:root { background: var(--bg); }

/* 桌面端：低饱和渐变 + 噪点纹理背景 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, var(--accent-soft) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 80% 90%, var(--highlight) 0%, transparent 40%),
    var(--bg);
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.025;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: multiply;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

img {
  display: block;
  max-width: 100%;
  -webkit-user-drag: none;
}

/* —— 滚动条 —— */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* —— 文字工具类 —— */
.display-font { font-family: var(--font-display); }
.mono-font { font-family: var(--font-mono); }

.title-l {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 1px;
  line-height: 1.2;
}
.title-m {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1.3;
}
.title-s {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.caption {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}
.micro {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* —— 应用根容器 —— */
#app {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* —— PC 端全屏模式：占满视口 —— */
@media (min-width: 769px) {
  [data-display-mode="fullscreen"] .phone-view,
  [data-display-mode="fullscreen"] .wechat-view,
  [data-display-mode="fullscreen"] .settings-view,
  [data-display-mode="fullscreen"] .mail-view,
  [data-display-mode="fullscreen"] .worldbook-view,
  [data-display-mode="fullscreen"] .mask-view,
  [data-display-mode="fullscreen"] .album-view,
  [data-display-mode="fullscreen"] .anniv-view,
  [data-display-mode="fullscreen"] .offline-view,
  [data-display-mode="fullscreen"] .ms-view,
  [data-display-mode="fullscreen"] .sms-view {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  [data-display-mode="fullscreen"] .phone-shell,
  [data-display-mode="fullscreen"] .wechat-shell,
  [data-display-mode="fullscreen"] .settings-shell,
  [data-display-mode="fullscreen"] .mail-shell,
  [data-display-mode="fullscreen"] .worldbook-shell,
  [data-display-mode="fullscreen"] .mask-shell,
  [data-display-mode="fullscreen"] .album-shell,
  [data-display-mode="fullscreen"] .anniv-shell,
  [data-display-mode="fullscreen"] .offline-shell,
  [data-display-mode="fullscreen"] .ms-shell,
  [data-display-mode="fullscreen"] .sms-shell {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100lvh;
    max-height: 100vh;
    max-height: 100lvh;
    border-radius: 0;
    box-shadow: none;
    border: none;
    overflow: hidden;
  }
}

/* —— PC 全屏模式：内容宽度限制，防止拉伸过度 —— */
@media (min-width: 769px) {
  [data-display-mode="fullscreen"] .ms-scroll,
  [data-display-mode="fullscreen"] .settings-body,
  [data-display-mode="fullscreen"] .mail-scroll,
  [data-display-mode="fullscreen"] .sms-scroll {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }
  [data-display-mode="fullscreen"] .ms-nav,
  [data-display-mode="fullscreen"] .settings-nav {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }
}

/* —— 视图切换动画 —— */
.view {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.view.active {
  opacity: 1;
  pointer-events: auto;
}

/* —— 通用工具 —— */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }

.hidden { display: none !important; }

/* —— 可访问性 —— */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* —— 选中态 —— */
::selection {
  background: var(--accent);
  color: var(--text-inverse);
}
