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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: transparent;
  color: #2d6a4f;
}

:root {
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --glass-bg: rgba(255, 255, 255, 0.22);
  --glass-border: rgba(255, 255, 255, 0.3);
  --green-dark: #2d6a4f;
  --green: #7cb342;
  --green-light: #a8e6cf;
  --green-soft: #dcedc1;
  --yellow-soft: #fff2b3;
}

.app-container {
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #a8e6cf 0%, #dcedc1 55%, #fff2b3 100%);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 28px rgba(45, 106, 79, 0.18);
}

#root {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.app-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 45%, rgba(124, 179, 66, 0.22), transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(168, 230, 207, 0.25), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* 自定义标题栏 */
.titlebar {
  height: 56px;
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 4px 24px rgba(45, 106, 79, 0.12);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  -webkit-app-region: drag;
  user-select: none;
  position: relative;
  z-index: 10;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.titlebar-left {
  display: flex;
  align-items: center;
  min-width: 160px;
  gap: 8px;
}

.titlebar-title {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #2d6a4f 0%, #7cb342 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-shadow: 0 2px 10px rgba(124, 179, 66, 0.25);
  filter: drop-shadow(0 2px 4px rgba(45, 106, 79, 0.1));
}

.titlebar-center {
  display: flex;
  align-items: center;
  gap: 4px;
  -webkit-app-region: no-drag;
  background: rgba(255, 255, 255, 0.5);
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 15px rgba(45, 106, 79, 0.12),
              inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: rgba(45, 106, 79, 0.2);
  margin: 0 6px;
}

.toolbar-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #2d6a4f;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-app-region: no-drag;
  position: relative;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.6);
  color: #2d6a4f;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(45, 106, 79, 0.2);
}

.toolbar-btn:active {
  background: rgba(255, 255, 255, 0.7);
  transform: translateY(0) scale(0.95);
}

.toolbar-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.toolbar-btn svg {
  width: 18px;
  height: 18px;
}

/* 窗口控制按钮 */
.titlebar-controls {
  display: flex;
  gap: 4px;
  -webkit-app-region: no-drag;
  min-width: 120px;
  justify-content: flex-end;
}

.control-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #2d6a4f;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.5);
}

.control-btn svg {
  width: 16px;
  height: 16px;
}

.control-btn.minimize:hover {
  background: rgba(255, 255, 255, 0.5);
}

.control-btn.maximize:hover {
  background: rgba(255, 255, 255, 0.5);
}

.control-btn.close:hover {
  background: #ef4444;
  color: white;
}

/* 主内容区 */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* 侧边栏 */
.sidebar {
  width: 200px;
  background: rgba(255, 255, 255, 0.45);
  border-right: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 4px 0 20px rgba(45, 106, 79, 0.12);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: relative;
  border-radius: var(--radius);
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, 
    rgba(168, 230, 207, 0.2) 0%, 
    rgba(220, 237, 193, 0.1) 100%);
  pointer-events: none;
}

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.category-tab {
  padding: 10px 12px;
  margin-bottom: 0;
  border-radius: 0;
  cursor: pointer;
  font-size: 13px;
  color: #2d6a4f;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  position: relative;
  z-index: 1;
}

.category-tab:first-of-type {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.category-tab:last-of-type {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border-bottom: none;
  margin-bottom: 0;
}

.category-tab:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(45, 106, 79, 0.2);
}

.category-tab.active {
  background: rgba(255, 255, 255, 0.7);
  color: #2d6a4f;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(45, 106, 79, 0.2),
              inset 0 1px 0 rgba(255, 255, 255, 0.4);
  border-left: 3px solid rgba(45, 106, 79, 0.7);
}

.category-tab.dragging {
  opacity: 0.5;
  background: rgba(168, 230, 207, 0.5);
}

.category-tab.drag-over {
  background: rgba(168, 230, 207, 0.6);
  box-shadow: 0 0 0 2px #2d6a4f inset;
}

/* 内容区域 */
.content-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  margin: 12px;
  contain: layout paint;
}

/* 分类分组容器 */
.categorized-apps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.category-section {
  background: rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 1px 6px rgba(45, 106, 79, 0.08);
  margin-bottom: 8px;
}

.category-section:first-child {
  border-radius: var(--radius);
}

.category-section:last-child {
  border-radius: var(--radius);
  margin-bottom: 0;
}

.category-title {
  padding: 12px 20px;
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.5) 0%, 
    rgba(255, 255, 255, 0.2) 100%);
  font-size: 13px;
  font-weight: 700;
  color: #2d6a4f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(45, 106, 79, 0.12);
}

/* 应用网格 */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0;
  width: 100%;
  contain: layout paint;
}

/* 每行最多15个 */
@media (min-width: 1650px) {
  .apps-grid {
    grid-template-columns: repeat(15, 1fr);
  }
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
  background: rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  padding: 40px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(45, 106, 79, 0.12);
}

.empty-state p {
  font-size: 18px;
  color: #2d6a4f;
  margin: 0;
  text-shadow: 0 2px 4px rgba(45, 106, 79, 0.12);
  font-weight: 500;
}

.empty-state button {
  padding: 14px 28px;
  background: linear-gradient(135deg, #a8e6cf, #dcedc1);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-sm);
  color: #2d6a4f;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(45, 106, 79, 0.18);
}

.empty-state button:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 25px rgba(45, 106, 79, 0.24);
  background: linear-gradient(135deg, #8bd7b8, #cfe7a8);
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 0;
  height: 0;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: transparent;
}

/* 为Firefox隐藏滚动条 */
* {
  scrollbar-width: none;
}

/* 设置面板 */
.settings-panel {
  background: rgba(255, 255, 255, 0.45);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 32px rgba(45, 106, 79, 0.12);
}

.settings-panel h3 {
  font-size: 16px;
  color: #2d6a4f;
  margin-bottom: 16px;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(45, 106, 79, 0.12);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.settings-label {
  font-size: 14px;
  color: #2d6a4f;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(45, 106, 79, 0.12);
}

.settings-hint {
  margin-top: 12px;
  font-size: 12px;
  color: rgba(45, 106, 79, 0.8);
  line-height: 1.6;
  padding: 12px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-sm);
  border-left: 3px solid rgba(45, 106, 79, 0.6);
  text-shadow: 0 1px 2px rgba(45, 106, 79, 0.12);
}

/* 开关切换 */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.5);
  transition: 0.3s;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 2px 4px rgba(45, 106, 79, 0.12);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, #a8e6cf, #dcedc1);
  border-color: rgba(45, 106, 79, 0.4);
  box-shadow: 0 0 10px rgba(45, 106, 79, 0.35),
              inset 0 1px 3px rgba(255, 255, 255, 0.4);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ── 外部文件拖放覆盖层 ───────────────────────────────────────── */
.external-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(45, 106, 79, 0.18);
  backdrop-filter: blur(3px);
  pointer-events: none;
}

.external-drop-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 56px;
  border: 2.5px dashed rgba(45, 106, 79, 0.6);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(45, 106, 79, 0.15);
  color: #2d6a4f;
}

.external-drop-box svg {
  width: 52px;
  height: 52px;
  opacity: 0.75;
}

.external-drop-box span {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
