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

body, html {
  height: 100%;
  overflow: hidden;
  font: 14px/27px "Microsoft YaHei", Arial, sans-serif;
  color: #333;
  -webkit-tap-highlight-color: transparent;
}

a {
  text-decoration: none;
  cursor: pointer;
}

ul, li {
  list-style: none;
}

/* 主题变量（默认：美团黄） */
body {
  --theme-primary: #FFC300;
  --theme-primary-2: #FFD24D;
  --theme-primary-dark: #E8AF00;
  --theme-light-bg: #FFFBEA;
  --theme-shadow: rgba(255, 195, 0, 0.35);
}

/* 淘宝闪购 */
body.theme-taobao {
  --theme-primary: #FF5000;
  --theme-primary-2: #FF7A33;
  --theme-primary-dark: #D63C00;
  --theme-light-bg: #FFF5EF;
  --theme-shadow: rgba(255, 80, 0, 0.35);
}

/* 京东外卖 */
body.theme-jingdong {
  --theme-primary: #E1251B;
  --theme-primary-2: #F04E45;
  --theme-primary-dark: #B71C13;
  --theme-light-bg: #FDEEEC;
  --theme-shadow: rgba(225, 37, 27, 0.35);
}

/* 顶部导航 */
#nav {
  height: 56px;
  background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-2) 60%, var(--theme-primary-2) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 8px var(--theme-shadow);
  position: relative;
  z-index: 20;
}

/* 底部高光线条，增加立体感 */
#nav::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
}

.logo {
  display: flex;
  align-items: center;
  padding: 4px 10px 4px 4px;
  border-radius: 20px;
  transition: background 0.25s, transform 0.25s;
}

.logo:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(1px);
}

.logo:active {
  transform: translateY(0);
}

.logo img {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
  transition: transform 0.3s;
}

.logo:hover img {
  transform: rotate(360deg);
}

.cname {
  margin-left: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.cname-domain {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  opacity: 0.85;
}

.cname-main {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
}

.badge {
  margin-left: 10px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 10px;
  white-space: nowrap;
}

.nav-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 1px rgba(0,0,0,0.1);
  white-space: nowrap;
}

/* 主容器 */
.container {
  width: 100%;
  position: absolute;
  top: 56px;
  bottom: 0;
  overflow: hidden;
  display: flex;
}

/* 左侧导航栏 */
.left-nav {
  width: 210px;
  min-width: 0;
  max-width: 400px;
  height: 100%;
  background: #fff;
  overflow: hidden;
  border-right: 1px solid #f0f0f0;
  box-shadow: 1px 0 6px rgba(0, 0, 0, 0.04);
  position: relative;
  transition: width 0.3s ease;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.left-nav.collapsed {
  width: 0;
  border-right: none;
}

.left-nav.collapsed .nav-content {
  visibility: hidden;
}

.left-nav.collapsed .resize-handle {
  display: none;
}

.left-nav.collapsed .toggle-btn {
  display: none;
}

/* 打开按钮（导航隐藏时显示） */
.open-btn {
  display: none;
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 60px;
  background: #e0e0e0;
  border: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.open-btn.show {
  display: flex;
}

.open-btn:hover {
  background: var(--theme-primary);
}

.open-btn:hover svg {
  fill: #fff;
}

.open-btn svg {
  width: 12px;
  height: 12px;
  fill: #666;
}

/* 导航列表 */
.nav-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}

.nav-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-content li {
  display: block;
}

.nav-content::-webkit-scrollbar {
  width: 4px;
}

.nav-content::-webkit-scrollbar-track {
  background: transparent;
}

.nav-content::-webkit-scrollbar-thumb {
  background: #e5cfc2;
  border-radius: 2px;
}

/* 分类标题 */
.nav-category {
  display: flex;
  align-items: center;
  height: 38px;
  margin: 8px 8px 0;
  padding: 0 10px;
  background: #faf7f5;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s, color 0.2s;
  font-weight: 600;
  font-size: 13px;
  color: #666;
  position: relative;
}

.nav-category:hover {
  background: #f5efe9;
  color: var(--theme-primary-dark);
}

/* 网站项 */
.nav-items-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px 8px 2px;
}

.nav-items-grid.hidden {
  display: none !important;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 6px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
  min-width: 0;
}

.nav-item.hidden {
  display: none;
}

.nav-item:hover {
  border-color: var(--theme-primary-2);
  color: var(--theme-primary-dark);
  background: var(--theme-light-bg);
  box-shadow: 0 2px 6px var(--theme-shadow);
}

.nav-item:active {
  background: var(--theme-light-bg);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-2) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px var(--theme-shadow);
}

.open-new-btn {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 2px;
}

.open-new-btn a {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  color: #fff;
  background: var(--theme-primary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}

.open-new-btn.has-desc a {
  background: #4CAF50;
}

.open-new-btn a:hover {
  background: var(--theme-primary-dark);
}

.open-new-btn.has-desc a:hover {
  background: #43A047;
}

.open-new-btn.triangle-left a::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 12px;
  border-width: 0 5px 5px 5px;
  border-style: solid;
  border-color: transparent transparent var(--theme-primary) transparent;
}

.open-new-btn.triangle-left a:hover::after {
  border-color: transparent transparent var(--theme-primary-dark) transparent;
}

.open-new-btn.triangle-right a::after {
  content: '';
  position: absolute;
  top: -5px;
  right: 12px;
  border-width: 0 5px 5px 5px;
  border-style: solid;
  border-color: transparent transparent var(--theme-primary) transparent;
}

.open-new-btn.triangle-right a:hover::after {
  border-color: transparent transparent var(--theme-primary-dark) transparent;
}

/* 加载更多按钮 */
.load-more-btn {
  display: block;
  width: 100%;
  padding: 6px;
  margin: 4px auto 0;
  font-size: 11px;
  color: #999;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: center;
  transition: color 0.2s;
  grid-column: 1 / -1;
}

.load-more-btn:hover {
  color: var(--theme-primary-dark);
}

.nav-item a {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 简介悬停提示 */
/* 拖拽手柄 */
.resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  background: transparent;
  cursor: default;
  z-index: 10;
}

.resize-handle:hover {
  background: var(--theme-shadow);
  cursor: col-resize;
}

.resize-handle.active {
  background: var(--theme-primary);
  cursor: col-resize;
}

/* 折叠按钮 */
.toggle-btn {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 20px;
  height: 60px;
  background: #e0e0e0;
  border: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 11;
  transition: all 0.2s;
}

.toggle-btn:hover {
  background: var(--theme-primary);
}

.toggle-btn:hover svg {
  fill: #fff;
}

.toggle-btn svg {
  width: 12px;
  height: 12px;
  fill: #666;
  transition: transform 0.3s;
}

.left-nav.collapsed .toggle-btn svg {
  transform: rotate(180deg);
}

/* 右侧内容区 */
.main {
  flex: 1;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 主题切换栏 */
.theme-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 10px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.theme-btn {
  padding: 4px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: #666;
  background: #f7f7f7;
  border: 1px solid #e5e5e5;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.theme-btn:hover {
  color: var(--theme-primary-dark);
  border-color: var(--theme-primary);
  background: var(--theme-light-bg);
}

.theme-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-2) 100%);
  border-color: transparent;
  box-shadow: 0 2px 6px var(--theme-shadow);
}

/* 红包领取栏 */
.redpacket-bar {
  display: none;
  align-items: stretch;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
  overflow-x: auto;
}

.redpacket-bar.show {
  display: flex;
}

.redpacket-label {
  display: flex;
  align-items: center;
  gap: 4px;
  align-self: center;
  padding-right: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #E1251B;
  white-space: nowrap;
}

.redpacket-label .rl-icon {
  font-size: 16px;
}

.redpacket-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 5px 14px;
  background: linear-gradient(180deg, #FF6A5A 0%, #E1251B 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
  box-shadow: 0 3px 8px rgba(225, 37, 27, 0.28);
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.redpacket-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(225, 37, 27, 0.38);
}

.redpacket-btn.active {
  background: linear-gradient(180deg, #E1251B 0%, #B71C13 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 215, 120, 0.7);
}

.redpacket-btn .rp-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.redpacket-btn .rp-tag {
  font-size: 10px;
  color: #FFE9A8;
  white-space: nowrap;
}

.redpacket-btn .rp-open {
  position: absolute;
  top: 2px;
  right: 5px;
  font-size: 10px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
}

.redpacket-btn .rp-open:hover {
  color: #fff;
}

/* 工具栏（保留 #engine 样式） */
#engine {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255,255,255,0.8);
  z-index: 10;
}

.loading.show {
  display: flex;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #eee;
  border-top-color: var(--theme-primary-dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 4px;
  font-size: 13px;
  color: #999;
}

.loading-domain {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--theme-primary-dark);
  cursor: pointer;
  text-decoration: underline;
  user-select: none;
}

.loading-domain:hover {
  color: var(--theme-primary-dark);
}

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

/* 拖拽时禁止选中 */
body.dragging {
  cursor: col-resize;
  user-select: none;
}

body.dragging iframe {
  pointer-events: none;
}

/* 移动端适配 */
@media (max-width: 768px) {
  #nav {
    height: 46px;
    padding: 0 12px;
  }

  .logo img {
    width: 28px;
    height: 28px;
  }

  .cname-domain {
    font-size: 9px;
  }

  .cname-main {
    font-size: 14px;
  }

  .badge {
    display: none;
  }

  .nav-hint {
    display: none;
  }

  .container {
    top: 46px;
  }
  
  .left-nav {
    width: 160px;
  }
  
  .left-nav.collapsed {
    width: 0;
  }
  
  .nav-category {
    height: 32px;
    font-size: 11px;
    padding: 0 8px;
  }
  
  .nav-items-grid {
    gap: 3px;
    padding: 4px;
  }
  
  .nav-item {
    height: 28px;
  }
  
  .nav-item a {
    font-size: 11px;
  }
  
  .toggle-btn {
    height: 50px;
  }
  
  .open-btn {
    height: 50px;
  }

  .redpacket-bar {
    gap: 6px;
    padding: 6px 8px;
  }

  .redpacket-btn {
    min-width: 76px;
    padding: 4px 8px;
  }

  .redpacket-btn .rp-name {
    font-size: 11px;
  }
}
