/* ============================================================
   HelioFox Storage · 设计令牌与基础样式
   ============================================================ */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Consolas, "Courier New", monospace;

  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius: 13px;
  --radius-lg: 18px;
  --radius-xl: 26px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --sidebar-w: 264px;
  --topbar-h: 68px;

  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 52%, #38bdf8 115%);

  --z-dropdown: 400;
  --z-sticky: 300;
  --z-drawer: 500;
  --z-modal: 600;
  --z-toast: 900;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fa;
  --bg-deep: #eaeef7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f9;
  --surface-hover: #f2f5fb;
  --border: #e4e9f2;
  --border-strong: #d3dae6;
  --text: #0e1729;
  --text-2: #566579;
  --text-3: #8a97ab;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-2: #7c3aed;
  --accent-soft: rgba(79, 70, 229, 0.09);
  --accent-soft-strong: rgba(79, 70, 229, 0.16);
  --ring: rgba(79, 70, 229, 0.3);
  --danger: #dc2653;
  --danger-soft: rgba(220, 38, 83, 0.09);
  --success: #0f9d6e;
  --success-soft: rgba(15, 157, 110, 0.1);
  --warning: #d97706;
  --overlay: rgba(15, 23, 42, 0.45);
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 14px -2px rgba(16, 24, 40, 0.09), 0 2px 6px -2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 18px 44px -12px rgba(16, 24, 40, 0.22), 0 6px 16px -8px rgba(16, 24, 40, 0.1);
  --shadow-xl: 0 34px 70px -20px rgba(15, 23, 42, 0.32);
  --glass: rgba(255, 255, 255, 0.72);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070910;
  --bg-deep: #04060b;
  --surface: #0f131c;
  --surface-2: #141926;
  --surface-3: #1b2130;
  --surface-hover: #171d2a;
  --border: #212838;
  --border-strong: #2e374b;
  --text: #eef1f8;
  --text-2: #9aa6bb;
  --text-3: #6b7789;
  --accent: #6d6ff5;
  --accent-hover: #818cf8;
  --accent-2: #a78bfa;
  --accent-soft: rgba(109, 111, 245, 0.15);
  --accent-soft-strong: rgba(109, 111, 245, 0.26);
  --ring: rgba(129, 140, 248, 0.4);
  --danger: #fb5b7d;
  --danger-soft: rgba(251, 91, 125, 0.13);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.13);
  --warning: #fbbf24;
  --overlay: rgba(3, 6, 12, 0.68);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.36);
  --shadow-md: 0 8px 24px -6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, 0.72), 0 8px 20px -10px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 42px 90px -24px rgba(0, 0, 0, 0.8);
  --glass: rgba(18, 23, 34, 0.72);
}

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

/* 关键：元素上的 display 会覆盖 UA 的 [hidden]，这里强制生效 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

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

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

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

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

button {
  border: 0;
  background: none;
  cursor: pointer;
}

svg {
  display: block;
}

img {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--accent-soft-strong);
  color: var(--text);
}

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

/* 滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
  background-clip: content-box;
}

/* ============================================================ Toast */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: var(--z-toast);
  pointer-events: none;
  width: max-content;
  max-width: min(92vw, 560px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  animation: toast-in 0.32s var(--ease-out) both;
  pointer-events: auto;
}

.toast.out {
  animation: toast-out 0.24s var(--ease) forwards;
}

.toast .toast-ic {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
}

.toast.success .toast-ic {
  color: var(--success);
  background: var(--success-soft);
}

.toast.error .toast-ic {
  color: var(--danger);
  background: var(--danger-soft);
}

.toast.info .toast-ic {
  color: var(--accent);
  background: var(--accent-soft);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
}

/* ============================================================ 通用按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: background 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease),
    transform 0.12s var(--ease), box-shadow 0.16s var(--ease);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn-primary {
  color: #fff;
  background: var(--brand-gradient);
  border-color: transparent;
  box-shadow: 0 4px 14px -4px rgba(99, 102, 241, 0.55);
}

.btn-primary:hover {
  color: #fff;
  background: var(--brand-gradient);
  filter: brightness(1.07);
  box-shadow: 0 8px 22px -6px rgba(99, 102, 241, 0.6);
}

.btn-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  background: var(--danger-soft);
}

.btn-danger:hover {
  color: #fff;
  background: var(--danger);
  border-color: transparent;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: transparent;
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--text-2);
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
  flex: none;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

/* ============================================================ 通用动画 */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.loading .spinner {
  display: block;
}

.loading .btn-label {
  opacity: 0.7;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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