:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-main: #0f172a;
  --bg-topbar: rgba(15, 23, 42, 0.94);
  --bg-sidebar: #1e293b;
  --border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --card-bg: #1e293b;
  --topbar-height: 52px;
  --bottombar-height: 34px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100vw;
  max-width: 100vw;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
  background: #090d16;
  color: var(--text-main);
  position: relative;
  overscroll-behavior: none;
}

/* 顶部固定控制栏 */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: #fff;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.btn-icon:hover { background: #334155; }

.site-branding {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon { font-size: 20px; }
.site-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #f1f5f9;
}
.badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.badge-sub {
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 600px;
  margin: 0 16px;
}
.current-site-info {
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.site-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  flex-shrink: 0;
}
.nav-btn {
  background: #1e293b;
  border: 1px solid var(--border);
  color: #cbd5e1;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.nav-btn:hover { background: #334155; color: #fff; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #334155; color: #f1f5f9; }
.btn-secondary:hover { background: #475569; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: #cbd5e1; }
.btn-outline:hover { background: #334155; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* 主工作区布局 */
.main-layout {
  position: absolute;
  top: var(--topbar-height);
  bottom: var(--bottombar-height);
  left: 0;
  right: 0;
  display: flex;
  width: 100%;
  height: calc(100% - var(--topbar-height) - var(--bottombar-height));
  overflow: hidden;
}

/* 左侧抽屉菜单 */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, width 0.3s ease;
  z-index: 40;
  flex-shrink: 0;
}
.sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute;
  height: 100%;
}

.sidebar-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
  display: flex;
  align-items: center;
}
.sidebar-search input {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  color: #fff;
  font-size: 13px;
  outline: none;
}
.sidebar-search input:focus { border-color: var(--primary); }
.btn-clear {
  position: absolute;
  right: 18px;
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 13px;
}

.category-tabs {
  display: flex;
  padding: 8px 12px;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: #172033;
}
.cat-tab {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.cat-tab.active {
  background: rgba(37, 99, 235, 0.25);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.5);
  font-weight: 600;
}

.site-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.site-card {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
}
.site-card:hover {
  background: #1e293b;
  border-color: #475569;
  transform: translateY(-1px);
}
.site-card.active {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.12);
}
.site-card-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  overflow: hidden;
}
.site-card-icon { font-size: 16px; flex-shrink: 0; }
.site-card-name {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0.6;
}
.site-card:hover .site-card-actions { opacity: 1; }
.btn-card-del {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}

.sidebar-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  background: #172033;
}
.btn-link {
  background: none;
  border: none;
  color: #60a5fa;
  cursor: pointer;
  font-size: 11px;
}

/* 右侧内容主区 */
.content-area {
  flex: 1;
  position: relative;
  background: #ffffff;
  overflow: hidden;
}

.main-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  display: block;
}

/* 跨域拦截优雅退回提示卡片 */
.embed-fallback {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}
.fallback-card {
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}
.fallback-icon { font-size: 42px; margin-bottom: 12px; }
.fallback-card h3 { font-size: 18px; margin-bottom: 10px; color: #f1f5f9; }
.fallback-card p { font-size: 13.5px; color: #cbd5e1; line-height: 1.6; margin-bottom: 8px; }
.fallback-card code { background: #0f172a; padding: 2px 6px; border-radius: 4px; color: #38bdf8; }
.fallback-sub { font-size: 12px; color: #94a3b8; margin-bottom: 18px; }
.fallback-actions { display: flex; justify-content: center; gap: 12px; }

/* 悬浮层与可拖拽组件 */
.floating-layer {
  position: absolute;
  top: var(--topbar-height);
  bottom: var(--bottombar-height);
  left: 0;
  right: 0;
  pointer-events: none; /* 让鼠标穿透，仅组件本身接收事件 */
  z-index: 60;
  overflow: hidden;
}

.draggable-widget {
  position: absolute;
  pointer-events: auto;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  touch-action: none;
  user-select: none;
  min-width: 140px;
  min-height: 50px;
  display: flex;
  flex-direction: column;
}

.widget-header {
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.85);
  border-top-left-radius: 9px;
  border-top-right-radius: 9px;
  cursor: grab;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.widget-header:active { cursor: grabbing; }
.widget-title { font-size: 12px; font-weight: 700; color: #e2e8f0; }
.widget-ctrls { display: flex; gap: 4px; }
.ctrl-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 12px;
  padding: 1px 4px;
}
.ctrl-btn:hover { color: #fff; }

.widget-body {
  padding: 10px 12px;
  font-size: 12.5px;
  flex: 1;
}
.promo-box strong { color: #f59e0b; display: block; margin-bottom: 4px; }
.promo-box p { font-size: 11.5px; color: #cbd5e1; margin-bottom: 8px; line-height: 1.4; }

/* 拖拽缩放手柄 */
.resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, #94a3b8 50%);
  border-bottom-right-radius: 9px;
}

/* 透明度调节浮窗 */
.opacity-popover {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  z-index: 120;
  width: 140px;
}
.opacity-slider { width: 100%; margin-top: 4px; cursor: pointer; }

/* 悬浮 FAB 按钮 */
.fab-widget {
  border-radius: 50%;
  min-width: 56px;
  min-height: 56px;
  background: transparent;
  border: none;
  box-shadow: none;
}
.fab-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.5);
  cursor: grab;
  border: 2px solid #60a5fa;
  transition: transform 0.15s;
}
.fab-circle:active { cursor: grabbing; transform: scale(0.95); }

/* 底部固定状态栏 */
.bottombar {
  height: var(--bottombar-height);
  background: #0b1120;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 50;
}
.status-tag { color: #10b981; font-weight: 600; margin-right: 8px; }
.status-url { color: #cbd5e1; }

/* 模态弹窗 */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-dialog {
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 15px; color: #f1f5f9; }
.btn-close-modal { background: none; border: none; color: #94a3b8; font-size: 16px; cursor: pointer; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.form-group input, .form-group select {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: #fff;
  font-size: 13px;
  outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.hidden { display: none !important; }

/* 移动端全响应式与无横移锁死 (<= 768px) */
@media (max-width: 768px) {
  .topbar { padding: 0 10px; }
  .topbar-center { display: none; } /* 移动端隐藏中间冗余长文本 */
  .topbar-right .btn-outline { display: none; }
  .bottombar-center, .bottombar-right { display: none; }

  /* 移动端侧边栏以抽屉式覆盖 */
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 260px;
    box-shadow: 6px 0 24px rgba(0,0,0,0.6);
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
  }

  .draggable-widget {
    max-width: calc(100vw - 32px) !important;
  }
}