:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #4a9eff;
  --text: #e0e0e0;
  --text2: #a0a0a0;
  --border: #2a2a4a;
  --danger: #e74c3c;
  --success: #2ecc71;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* 顶部工具栏 */
#toolbar {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  gap: 6px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 48px;
  -webkit-app-region: no-drag;
}

#toolbar .nav-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#toolbar .nav-btn:hover { background: var(--surface2); color: var(--text); }
#toolbar .nav-btn:disabled { opacity: 0.3; cursor: default; }

#toolbar .sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

#url-bar-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

#url-bar {
  width: 100%;
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
#url-bar:focus { border-color: var(--accent); }

#go-btn {
  position: absolute;
  right: 4px;
  background: var(--accent);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: none;
}
#url-bar:focus ~ #go-btn, #go-btn:hover { display: flex; align-items: center; justify-content: center; }

#toolbar .tool-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
#toolbar .tool-btn:hover { background: var(--surface2); color: var(--text); }
#toolbar .tool-btn.active { color: var(--accent); }

/* 标签栏 */
#tab-bar {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 36px;
  align-items: flex-end;
  overflow-x: auto;
  scrollbar-width: none;
}
#tab-bar::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  padding: 4px 16px;
  height: 32px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  margin-left: 2px;
  cursor: pointer;
  font-size: 12px;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  gap: 6px;
  color: var(--text2);
}
.tab.active { background: var(--surface2); color: var(--text); }
.tab .tab-close {
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  cursor: pointer;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tab:hover .tab-close, .tab.active .tab-close { opacity: 0.7; }
.tab .tab-close:hover { opacity: 1; background: rgba(255,255,255,0.15); }

#add-tab-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 18px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  flex-shrink: 0;
}
#add-tab-btn:hover { color: var(--text); }

/* 主内容区 */
#main-area {
  display: flex;
  height: calc(100vh - 84px);
}

#browser-panel {
  flex: 1;
  position: relative;
}

#browser-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* 起始页 */
#start-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 20px;
}

#start-page .logo { font-size: 48px; font-weight: 700; color: var(--accent); }
#start-page .subtitle { color: var(--text2); font-size: 14px; }

#start-page .quick-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 600px;
}
#start-page .quick-link {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  text-align: center;
  min-width: 100px;
  transition: all 0.2s;
}
#start-page .quick-link:hover {
  background: var(--surface2);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* 侧边栏 */
.sidebar {
  width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s;
}
.sidebar.collapsed { width: 0; border: none; }

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar-header button {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
}
.sidebar-header button:hover { color: var(--text); }

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* AI 面板 */
#ai-input-wrap {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
#ai-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#ai-input:focus { border-color: var(--accent); }
#ai-send {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
#ai-send:disabled { opacity: 0.5; cursor: default; }
#ai-response {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.history-item, .bookmark-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.history-item .url, .bookmark-item .url {
  color: var(--accent);
  cursor: pointer;
  word-break: break-all;
}
.history-item .url:hover, .bookmark-item .url:hover { text-decoration: underline; }
.history-item .title, .bookmark-item .title {
  color: var(--text);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item .time, .bookmark-item .time {
  color: var(--text2);
  font-size: 11px;
  margin-top: 2px;
}
.bookmark-item .del-btn {
  float: right;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 12px;
  cursor: pointer;
  color: var(--text2);
  border-bottom: 2px solid transparent;
}
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* 用户菜单 */
#user-menu {
  position: relative;
}
#user-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
#user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 140px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
#user-dropdown.show { display: block; }
#user-dropdown a {
  display: block;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
}
#user-dropdown a:hover { background: var(--surface2); }

/* Toast */
#toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
#toast.show { opacity: 1; }
#toast.error { border: 1px solid var(--danger); }

/* 翻译弹窗 */
#translate-modal.show { display: flex !important; align-items:center; justify-content:center; position:fixed; inset:0; z-index:9999; }
.translate-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.6); }
.translate-dialog { position:relative; width:520px; max-width:95vw; max-height:85vh; background:var(--surface); border:1px solid var(--border); border-radius:16px; display:flex; flex-direction:column; overflow:hidden; z-index:1; }
.translate-header { display:flex; justify-content:space-between; align-items:center; padding:14px 20px; border-bottom:1px solid var(--border); font-size:15px; font-weight:600; }
.translate-header button { background:none; border:none; color:var(--text2); cursor:pointer; font-size:18px; }
.translate-header button:hover { color:var(--text); }
.translate-body { padding:16px 20px; overflow-y:auto; }
.translate-tabs { display:flex; gap:0; margin-bottom:16px; border-bottom:1px solid var(--border); }
.translate-tab { padding:8px 16px; cursor:pointer; font-size:13px; color:var(--text2); border-bottom:2px solid transparent; }
.translate-tab.active { color:var(--accent); border-bottom-color:var(--accent); }
#translate-input { width:100%; background:var(--bg); border:1px solid var(--border); border-radius:8px; color:var(--text); font-size:13px; padding:10px; resize:vertical; outline:none; font-family:inherit; }
#translate-input:focus { border-color:var(--accent); }
.translate-row { display:flex; gap:8px; margin-top:12px; }
.translate-row select { flex:1; padding:8px 12px; background:var(--bg); border:1px solid var(--border); border-radius:8px; color:var(--text); font-size:13px; outline:none; }
.translate-row button { background:var(--accent); border:none; color:#fff; padding:8px 20px; border-radius:8px; cursor:pointer; font-size:13px; white-space:nowrap; }
.translate-row button:hover { opacity:0.85; }
.translate-row button:disabled { opacity:0.5; cursor:default; }
#translate-result, #translate-page-result { margin-top:14px; padding:14px; background:var(--bg); border:1px solid var(--border); border-radius:8px; font-size:13px; line-height:1.7; max-height:300px; overflow-y:auto; white-space:pre-wrap; }
