/* 领域展开 · 统一 UX 与苹果级动效底座 (2026-11-25 宪法版)
 * 原则：只动 transform/opacity 合成层、统一曲线节奏、跟手可打断、全端深浅色成立、严格尊重 prefers-reduced-motion。
 */

:root {
  /* 统一苹果级动效曲线与节奏 */
  --ly-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ly-ease-spring: cubic-bezier(0.34, 1.38, 0.64, 1);
  --ly-ease-press: cubic-bezier(0.2, 0, 0, 1);
  --ly-dur-fast: 140ms;
  --ly-dur-base: 220ms;
  --ly-dur-slow: 300ms;

  /* 深色主题默认表面（与主站深色系一致） */
  --ly-surface-popover: rgba(20, 22, 29, 0.94);
  --ly-surface-pill: rgba(255, 255, 255, 0.08);
  --ly-surface-pill-hover: rgba(255, 255, 255, 0.16);
  --ly-border-subtle: rgba(255, 255, 255, 0.14);
  --ly-border-strong: rgba(255, 255, 255, 0.30);
  --ly-ink-primary: #eef2f8;
  --ly-ink-muted: #98a2b3;
  --ly-accent: #4c8dff;
  --ly-accent-soft: rgba(76, 141, 255, 0.16);
  --ly-accent-soft-hover: rgba(76, 141, 255, 0.28);
  --ly-accent-ink: #dbeafe;
  --ly-shadow-popover: 0 18px 48px rgba(0, 0, 0, 0.58), 0 2px 8px rgba(0, 0, 0, 0.32);
  --ly-toast-bg: rgba(24, 27, 36, 0.94);
  --ly-toast-ink: #f4f7fb;
  --ly-toast-border: rgba(255, 255, 255, 0.14);
  --ly-focus-ring: rgba(96, 165, 250, 0.72);
}

/* 浅色主题适配（含系统浅色回退） */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="eye-care"]) {
    --ly-surface-popover: rgba(255, 255, 255, 0.96);
    --ly-surface-pill: rgba(15, 23, 42, 0.06);
    --ly-surface-pill-hover: rgba(15, 23, 42, 0.12);
    --ly-border-subtle: rgba(15, 23, 42, 0.12);
    --ly-border-strong: rgba(15, 23, 42, 0.24);
    --ly-ink-primary: #0f172a;
    --ly-ink-muted: #475569;
    --ly-accent: #2563eb;
    --ly-accent-soft: rgba(37, 99, 235, 0.10);
    --ly-accent-soft-hover: rgba(37, 99, 235, 0.18);
    --ly-accent-ink: #1d4ed8;
    --ly-shadow-popover: 0 16px 40px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.06);
    --ly-toast-bg: rgba(15, 23, 42, 0.92);
    --ly-toast-ink: #f8fafc;
    --ly-toast-border: rgba(255, 255, 255, 0.12);
  }
}
html[data-theme="light"],
[data-theme="light"] {
  --ly-surface-popover: rgba(255, 255, 255, 0.96);
  --ly-surface-pill: rgba(15, 23, 42, 0.06);
  --ly-surface-pill-hover: rgba(15, 23, 42, 0.12);
  --ly-border-subtle: rgba(15, 23, 42, 0.12);
  --ly-border-strong: rgba(15, 23, 42, 0.24);
  --ly-ink-primary: #0f172a;
  --ly-ink-muted: #475569;
  --ly-accent: #2563eb;
  --ly-accent-soft: rgba(37, 99, 235, 0.10);
  --ly-accent-soft-hover: rgba(37, 99, 235, 0.18);
  --ly-accent-ink: #1d4ed8;
  --ly-shadow-popover: 0 16px 40px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.06);
  --ly-toast-bg: rgba(15, 23, 42, 0.92);
  --ly-toast-ink: #f8fafc;
  --ly-toast-border: rgba(255, 255, 255, 0.12);
}

/* 护眼主题适配 */
html[data-theme="eye-care"],
[data-theme="eye-care"] {
  --ly-surface-popover: rgba(247, 243, 232, 0.96);
  --ly-surface-pill: rgba(68, 56, 36, 0.07);
  --ly-surface-pill-hover: rgba(68, 56, 36, 0.13);
  --ly-border-subtle: rgba(68, 56, 36, 0.14);
  --ly-border-strong: rgba(68, 56, 36, 0.28);
  --ly-ink-primary: #2d261a;
  --ly-ink-muted: #6b5d47;
  --ly-accent: #2563eb;
  --ly-accent-soft: rgba(37, 99, 235, 0.10);
  --ly-accent-soft-hover: rgba(37, 99, 235, 0.18);
  --ly-accent-ink: #1e40af;
  --ly-shadow-popover: 0 16px 40px rgba(45, 38, 26, 0.14), 0 2px 6px rgba(45, 38, 26, 0.06);
}

/* 1. 内部 OMS 入口默认零闪烁隐藏，仅授权会话可见 */
a.account-oms,
a[href^="/api/oms/"],
a[href^="/oms"],
.ly-hide-internal {
  display: none !important;
}
html[data-ly-oms-allowed="1"] a.account-oms,
html[data-ly-oms-allowed="1"] a[href^="/api/oms/"],
html[data-ly-oms-allowed="1"] a[href^="/oms"] {
  display: inline-flex !important;
}

/* 2. 全局等宽数字：余额、倒计时、单价变化时零水平抖动 */
.price,
[class*="balance"],
[class*="price"],
[class*="count"],
[class*="timer"],
[data-ly-tabular="1"] {
  font-variant-numeric: tabular-nums;
}

/* 3. 统一可交互触觉反馈：只动 transform/opacity 合成层，不触发布局重排 */
button:not(:disabled),
a[role="button"],
.ly-api-nav-link,
.ly-account-api-bar a {
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--ly-dur-fast) var(--ly-ease-press),
    opacity var(--ly-dur-fast) var(--ly-ease-out);
}
button:not(:disabled):active,
a[role="button"]:active,
.ly-api-nav-link:active,
.ly-account-api-bar a:active {
  transform: scale(0.975);
}

/* 4. 统一清晰焦点环（键盘操作可见，鼠标点击不打扰） */
:focus-visible {
  outline: 2px solid var(--ly-focus-ring);
  outline-offset: 2px;
}

/* 5. 侧栏平滑滚动（笔记本屏高不挤出底部账号/主题） */
aside,
nav[class*="side"],
[class*="sidebar"] {
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* 6. 悬浮按钮防遮挡定位（平滑避让主 CTA） */
button[data-ly-helper-shifted="1"],
[data-ly-helper-shifted="1"] {
  bottom: 84px !important;
  right: 18px !important;
  z-index: 40 !important;
}
[data-ly-intro-btn="1"] {
  bottom: 24px !important;
  right: 20px !important;
  left: auto !important;
  transform: none !important;
}
@media (max-width: 768px) {
  [data-ly-intro-btn="1"] {
    bottom: 88px !important;
    right: 12px !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
  }
}

/* 7. 浮层 / 下拉菜单：不透底、带苹果级轻柔弹入动效、深浅色自适应 */
@keyframes ly-popover-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.975);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes ly-dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes ly-toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

[data-ly-solid-popover="1"] {
  background: var(--ly-surface-popover) !important;
  backdrop-filter: saturate(180%) blur(18px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(18px) !important;
  border: 1px solid var(--ly-border-subtle) !important;
  box-shadow: var(--ly-shadow-popover) !important;
  z-index: 60 !important;
  animation: ly-popover-in var(--ly-dur-base) var(--ly-ease-out) both;
  will-change: transform, opacity;
}

[role="dialog"][data-ly-animated="1"] {
  animation: ly-dialog-in var(--ly-dur-slow) var(--ly-ease-out) both;
}

/* 8. 裂图优雅降级，不露破图图标 */
img.ly-broken-fallback {
  opacity: 0 !important;
}

/* 9. 首页导航“API 接入”胶囊入口 */
.ly-api-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ly-ink-primary) !important;
  border: 1px solid var(--ly-border-subtle);
  background: var(--ly-surface-pill);
  text-decoration: none !important;
  white-space: nowrap;
}
@media (hover: hover) {
  .ly-api-nav-link:hover {
    background: var(--ly-surface-pill-hover);
    border-color: var(--ly-border-strong);
    transform: translateY(-1px);
  }
}

/* 10. 创作台“我的账号”弹窗 API 快捷入口 */
.ly-account-api-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 6px;
  padding-top: 10px;
  border-top: 1px solid var(--ly-border-subtle);
}
.ly-account-api-bar a {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ly-accent-ink);
  background: var(--ly-accent-soft);
  border: 1px solid rgba(76, 141, 255, 0.30);
  text-decoration: none;
}
@media (hover: hover) {
  .ly-account-api-bar a:hover {
    background: var(--ly-accent-soft-hover);
    transform: translateY(-1px);
  }
}

/* 11. 统一非阻塞苹果风 Toast 轻提示 */
#ly-toast-root {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  transform: translate(-50%, 0);
  z-index: 2147482500;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ly-toast {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: min(90vw, 420px);
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--ly-toast-bg);
  color: var(--ly-toast-ink);
  border: 1px solid var(--ly-toast-border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  font: 500 13px/1.4 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  animation: ly-toast-in var(--ly-dur-base) var(--ly-ease-out) both;
  transition: opacity var(--ly-dur-fast) var(--ly-ease-out), transform var(--ly-dur-fast) var(--ly-ease-out);
}
.ly-toast.is-leaving {
  opacity: 0;
  transform: translateY(6px) scale(0.96);
}
.ly-toast-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  flex: none;
}
.ly-toast[data-tone="error"] .ly-toast-dot {
  background: #f87171;
}
.ly-toast[data-tone="info"] .ly-toast-dot {
  background: #60a5fa;
}

/* 12. 创作台 Apple 级视觉层次、毛玻璃与微动效跃升 (2026-11-25c) */
:root {
  --ly-glass-bar: rgba(15, 17, 23, 0.78);
  --ly-glass-sidebar: rgba(13, 15, 20, 0.84);
  --ly-card-surface: linear-gradient(180deg, rgba(28, 32, 42, 0.92), rgba(20, 23, 31, 0.96));
  --ly-card-specular: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --ly-card-shadow: 0 10px 28px rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.2);
  --ly-card-shadow-hover: 0 18px 42px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(96, 165, 250, 0.26);
  --ly-ambient-glow: radial-gradient(72% 46% at 50% -10%, rgba(76, 141, 255, 0.13), transparent 70%);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="eye-care"]) {
    --ly-glass-bar: rgba(255, 255, 255, 0.78);
    --ly-glass-sidebar: rgba(248, 250, 252, 0.86);
    --ly-card-surface: linear-gradient(180deg, #ffffff, #f8fafc);
    --ly-card-specular: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --ly-card-shadow: 0 6px 20px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --ly-card-shadow-hover: 0 14px 32px rgba(15, 23, 42, 0.11), 0 0 0 1px rgba(37, 99, 235, 0.22);
    --ly-ambient-glow: radial-gradient(72% 46% at 50% -10%, rgba(37, 99, 235, 0.07), transparent 70%);
  }
}
html[data-theme="light"],
[data-theme="light"] {
  --ly-glass-bar: rgba(255, 255, 255, 0.78);
  --ly-glass-sidebar: rgba(248, 250, 252, 0.86);
  --ly-card-surface: linear-gradient(180deg, #ffffff, #f8fafc);
  --ly-card-specular: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --ly-card-shadow: 0 6px 20px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --ly-card-shadow-hover: 0 14px 32px rgba(15, 23, 42, 0.11), 0 0 0 1px rgba(37, 99, 235, 0.22);
  --ly-ambient-glow: radial-gradient(72% 46% at 50% -10%, rgba(37, 99, 235, 0.07), transparent 70%);
}

html[data-theme="eye-care"],
[data-theme="eye-care"] {
  --ly-glass-bar: rgba(245, 240, 226, 0.84);
  --ly-glass-sidebar: rgba(241, 235, 218, 0.88);
  --ly-card-surface: linear-gradient(180deg, #fbf8ef, #f3ede0);
  --ly-card-specular: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  --ly-card-shadow: 0 6px 20px rgba(68, 56, 36, 0.08), 0 1px 2px rgba(68, 56, 36, 0.05);
  --ly-card-shadow-hover: 0 14px 32px rgba(68, 56, 36, 0.14), 0 0 0 1px rgba(37, 99, 235, 0.22);
  --ly-ambient-glow: radial-gradient(72% 46% at 50% -10%, rgba(180, 140, 60, 0.09), transparent 70%);
}

@keyframes ly-view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.topbar {
  background: var(--ly-glass-bar) !important;
  backdrop-filter: saturate(180%) blur(22px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(22px) !important;
  border-bottom: 1px solid var(--ly-border-subtle) !important;
}
.sidebar {
  background: var(--ly-glass-sidebar) !important;
  backdrop-filter: saturate(180%) blur(22px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(22px) !important;
  border-right: 1px solid var(--ly-border-subtle) !important;
}
.workspace-main {
  background-image: var(--ly-ambient-glow);
  background-repeat: no-repeat;
  background-attachment: local;
}
.workspace-main > section {
  animation: ly-view-in var(--ly-dur-base) var(--ly-ease-out);
}

.gallery-card,
.asset-card,
.task-card,
.ph-card,
.nug-card,
.partner-card {
  border-radius: 16px !important;
  border: 1px solid var(--ly-border-subtle) !important;
  box-shadow: var(--ly-card-shadow), var(--ly-card-specular) !important;
  transition: transform var(--ly-dur-base) var(--ly-ease-out), opacity var(--ly-dur-fast) var(--ly-ease-out);
}
@media (hover: hover) {
  .gallery-card:hover,
  .asset-card:hover,
  .task-card:hover,
  .ph-card:hover,
  .nug-card:hover,
  .partner-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ly-card-shadow-hover), var(--ly-card-specular) !important;
  }
}

.filter-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--ly-surface-pill);
  border: 1px solid var(--ly-border-subtle);
}
.filter-tabs button {
  border-radius: 9px !important;
  font-weight: 550;
}
.filter-tabs button[aria-pressed="true"] {
  background: var(--ly-accent-soft) !important;
  color: var(--ly-accent-ink) !important;
  box-shadow: var(--ly-card-specular);
}

.sidebar button,
.sidebar a {
  border-radius: 11px !important;
}
.nav-canvas {
  box-shadow: var(--ly-card-specular);
}

/* 13. 严格尊重系统“减少动态效果” */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  button:active,
  a[role="button"]:active,
  .ly-api-nav-link:active,
  .ly-account-api-bar a:active {
    transform: none !important;
  }
}
