/* ===== 基础重置 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* 暖中性色系 */
  --bg: #FAF9F6;
  --bg-card: #FFFFFF;
  --bg-tag: #F0EFEA;
  --bg-tag-hover: #E8E7E2;
  --text: #2D2D2D;
  --text-light: #8C8C8C;
  --text-placeholder: #B0B0B0;
  --border: #E5E4E0;
  --border-hover: #D0CFC9;

  /* 点缀色：柔和珊瑚 */
  --accent: #E8826B;
  --accent-hover: #D96E56;
  --accent-light: #FFF4F1;
  --accent-text: #FFFFFF;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);

  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  /* 过渡 */
  --transition: 200ms ease-in-out;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-weight: 600;
}

/* ===== 登录页 ===== */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--bg-card);
  padding: 48px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  text-align: center;
  width: 360px;
  border: 1px solid var(--border);
}

.login-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius-pill);
}

.login-icon i {
  font-size: 28px;
  color: var(--accent);
}

.login-card h1 {
  font-size: 22px;
  margin-bottom: 6px;
  font-weight: 600;
}

.login-subtitle {
  color: var(--text-light);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-input-wrap {
  position: relative;
  margin-bottom: 16px;
}

.login-input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-placeholder);
  font-size: 14px;
  transition: color var(--transition);
}

#passwordInput {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}

#passwordInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

#passwordInput:focus + .login-input-icon,
.login-input-wrap:focus-within .login-input-icon {
  color: var(--accent);
}

.error-msg {
  color: #E8826B;
  font-size: 13px;
  min-height: 20px;
  margin-top: 12px;
}

/* ===== 按钮 ===== */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

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

.btn-logout {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 15px;
  transition: all var(--transition);
  flex-shrink: 0;
}

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

/* ===== 固定顶部搜索栏 ===== */
.search-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.search-container {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
  max-width: 600px;
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-placeholder);
  font-size: 14px;
  transition: color var(--transition);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  padding: 10px 40px 10px 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--bg-card);
}

#searchInput:focus ~ .search-icon,
.search-container:focus-within .search-icon {
  color: var(--accent);
}

.search-clear {
  position: absolute;
  right: 12px;
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 50%;
  font-size: 12px;
  transition: all var(--transition);
}

.search-clear:hover {
  background: var(--bg-tag-hover);
  color: var(--text);
}

.search-clear.visible {
  display: flex;
}

/* ===== 主页面 ===== */
.main-view {
  padding-top: 60px;
  max-width: 900px;
  margin: 0 auto;
}

/* ===== 快捷链接区 ===== */
.customs-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px 8px;
  overflow-x: auto;
  flex-wrap: wrap;
}

.custom-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  background: var(--bg-tag);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.custom-link:hover {
  background: var(--bg-tag-hover);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.custom-link .drag-handle {
  color: var(--text-placeholder);
  font-size: 11px;
  cursor: grab;
  padding-right: 2px;
}

.custom-link .drag-handle:active {
  cursor: grabbing;
}

.custom-link .favicon-sm {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}

.custom-link a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.custom-link .btn-delete {
  display: none;
  margin-left: 4px;
  color: var(--text-light);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px;
  border-radius: 50%;
  transition: all var(--transition);
}

.custom-link:hover .btn-delete {
  display: inline-flex;
}

.custom-link .btn-delete:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.btn-add-custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-add-custom:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  border-style: solid;
}

/* ===== Tab 切换 ===== */
.browser-tabs {
  display: flex;
  gap: 8px;
  padding: 8px 24px 12px;
  position: sticky;
  top: 60px;
  background: var(--bg);
  z-index: 90;
}

.browser-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.browser-tab:hover {
  border-color: var(--border-hover);
  background: var(--bg-card);
}

.browser-tab.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.browser-tab .tab-icon {
  font-size: 14px;
}

.browser-tab .tab-count {
  font-size: 11px;
  opacity: 0.7;
  background: rgba(255,255,255,0.2);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

.browser-tab:not(.active) .tab-count {
  background: var(--bg-tag);
  opacity: 1;
}

/* ===== 书签列表 ===== */
.bookmark-list {
  padding: 8px 24px 80px;
}

.bookmark-folder {
  margin-bottom: 6px;
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  font-weight: 600;
  font-size: 14px;
}

.folder-header:hover {
  background: var(--bg-card);
}

.folder-icon {
  font-size: 14px;
  color: var(--accent);
  transition: transform var(--transition);
  width: 16px;
  text-align: center;
}

.folder-header.collapsed .folder-icon {
  transform: rotate(-90deg);
}

.folder-count {
  color: var(--text-light);
  font-size: 12px;
  font-weight: 400;
  margin-left: 4px;
}

.bookmark-items {
  margin-left: 16px;
  overflow: hidden;
}

.bookmark-items.collapsed {
  display: none;
}

.bookmark-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.bookmark-item:hover {
  background: var(--bg-card);
}

.bookmark-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  flex: 1;
  width: 100%;
}

.bookmark-item .favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

.bookmark-item .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.bookmark-item .url {
  color: var(--text-light);
  font-size: 12px;
  margin-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
}

/* 搜索高亮 */
.search-highlight {
  background: var(--accent-light);
  color: var(--accent);
  padding: 1px 3px;
  border-radius: 3px;
  font-weight: 600;
}

/* 空状态 */
.empty-state {
  text-align: center;
  color: var(--text-light);
  padding: 60px 20px;
  font-size: 14px;
}

.empty-state i {
  font-size: 32px;
  margin-bottom: 12px;
  display: block;
  color: var(--border-hover);
}

/* ===== 编辑弹窗 ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.25);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-overlay.show {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  padding: 32px;
  border-radius: var(--radius-lg);
  width: 380px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.modal-card h3 {
  font-size: 18px;
  margin-bottom: 20px;
  font-weight: 600;
}

.modal-card label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
  font-weight: 500;
}

.modal-card input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  margin-bottom: 16px;
}

.modal-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--bg-card);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.btn-cancel {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-light);
  transition: all var(--transition);
}

.btn-cancel:hover {
  background: var(--bg-tag);
  color: var(--text);
  border-color: var(--border-hover);
}

.btn-save {
  padding: 10px 24px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--transition);
}

.btn-save:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-placeholder);
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .search-bar {
    padding: 0 16px;
  }

  .customs-bar,
  .browser-tabs,
  .bookmark-list {
    padding-left: 16px;
    padding-right: 16px;
  }

  .bookmark-item .url {
    display: none;
  }
}
