/* 办公工具箱 · 全局设计体系 */
:root {
  --bg: #e9edf4;
  --bg-subtle: linear-gradient(165deg, #eef2f8 0%, #e4eaf3 48%, #eceff6 100%);
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --border: #d8e0ec;
  --border-light: #eef2f8;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --warning: #d97706;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --header-h: auto;
  --transition: 0.18s ease;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "Cascadia Code", "Consolas", "SF Mono", monospace;
  --focus-ring: 0 0 0 3px var(--accent-soft);
}

[data-theme="dark"] {
  --bg: #0a101c;
  --bg-subtle: linear-gradient(165deg, #0b1220 0%, #0f172a 50%, #0a101c 100%);
  --surface: #151f32;
  --surface-elevated: #1a2740;
  --border: #2a3548;
  --border-light: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.15);
  --success-soft: rgba(34, 197, 94, 0.15);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
}

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  background-color: #e9edf4;
  color-scheme: light;
}

html[data-theme="dark"] {
  background-color: #0a101c;
  color-scheme: dark;
}

body {
  min-height: 100%;
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  background-image: var(--bg-subtle);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

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

button:focus:not(:focus-visible) { outline: none; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* 应用壳 */
.app-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 1280px;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.app-shell--tool { max-width: 1240px; }

/* 顶栏 */
.app-top {
  flex-shrink: 0;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 30;
}

[data-theme="dark"] .app-top {
  background: rgba(21, 31, 50, 0.92);
}

.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.brand { min-width: 0; flex: 1; }

.brand-link {
  display: inline-block;
  color: inherit;
  transition: opacity var(--transition);
}

.brand-link:hover { opacity: 0.85; }

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.brand .subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

/* 模块导航 · 分段控件风格 */
.module-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.module-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 16px;
  border-radius: calc(var(--radius-sm) - 2px);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.module-nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .module-nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
}

.module-nav-link.active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform 0.1s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.btn:active { transform: scale(0.98); }

.btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.76rem;
}

.btn-icon {
  padding: 7px 10px;
  min-width: 34px;
}

/* Toast · 顶部提示 */
.toast {
  position: fixed;
  top: max(16px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(calc(-100% - 16px));
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 500;
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.25s;
  z-index: 300;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .toast {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.toast--error {
  background: #dc2626;
  color: #fff;
}

[data-theme="dark"] .toast.toast--error {
  background: #b91c1c;
  border-color: #991b1b;
}

@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;
  }
}

@media (max-width: 767px) {
  .app-top { padding: 12px 14px 10px; }
  .top-row { margin-bottom: 10px; }
  .brand h1 { font-size: 1.05rem; }
  .module-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, transparent, #000 8px, #000 calc(100% - 24px), transparent);
  }
  .module-nav::-webkit-scrollbar { display: none; }
  .module-nav-link { padding: 6px 12px; font-size: 0.76rem; flex: 0 0 auto; min-width: 0; white-space: nowrap; }
}
