:root {
  --bg-page: #eef1f6;
  --bg-sidebar: #f4f6fa;
  --bg-main: #f5f7fb;
  --bg-card: #ffffff;
  --text-main: #111827;
  --text-strong: #0f172a;
  --text-muted: #6b7280;
  --text-light: #8a93a4;
  --line: #e5e7eb;
  --primary: #2f7af8;
  --primary-dark: #165cd4;
  --danger: #d1344b;
  --danger-bg: #fff1f4;
  --success: #0d8f5d;
  --shadow-soft: 0 8px 24px rgba(17, 24, 39, 0.06);
  --shadow-card: 0 2px 8px rgba(15, 23, 42, 0.06);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text-main);
  background: var(--bg-page);
  font-family: "Avenir Next", "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
  background: var(--bg-main);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 20px 16px 16px;
  background: var(--bg-sidebar);
  border-right: 1px solid #e6e9f0;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand-wrap {
  margin-bottom: 4px;
}

.brand-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #1f2937;
}

.brand-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  line-height: 1.45;
  font-size: 0.85rem;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  color: #fff;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  color: #374151;
  background: #fff;
  border: 1px solid #d4dae6;
  padding: 8px 12px;
}

.btn-secondary:hover {
  background: #f8fafc;
}

.side-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.category-panel {
  flex: 1;
  min-height: 260px;
  border: 1px solid #d9dfe9;
  border-radius: var(--radius-md);
  background: #fff;
  padding: 10px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.panel-head h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #374151;
}

.muted-text {
  color: #8a93a4;
  font-size: 0.8rem;
}

.category-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: calc(100vh - 320px);
  overflow: auto;
}

.category-item button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #374151;
  cursor: pointer;
  text-align: left;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font: inherit;
  font-size: 0.9rem;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.category-item button:hover {
  background: #f1f5ff;
  border-color: #dae5ff;
}

.category-item button.active {
  background: #ecf3ff;
  border-color: #cfe0ff;
  color: #1d4ed8;
  font-weight: 700;
}

.category-item .count {
  color: #8b94a7;
  font-size: 0.8rem;
}

.side-tip {
  margin: 0;
  color: #8a93a4;
  font-size: 0.8rem;
  line-height: 1.5;
}

.main-content {
  padding: 16px 20px 24px;
  overflow: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid #e2e7f1;
  border-radius: 14px;
  background: rgba(245, 247, 251, 0.95);
  backdrop-filter: blur(3px);
  padding: 10px 12px;
}

.search-wrap {
  flex: 1 1 100%;
}

.search-kicker {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #2357bb;
  background: #e8f0ff;
}

.search-wrap label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.86rem;
  color: #344054;
  font-weight: 700;
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-row input {
  flex: 1;
}

.search-wrap input {
  width: 100%;
  border: 1px solid #bfcbe0;
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(47, 122, 248, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 122, 248, 0.16);
}

.topbar-meta {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #6b7280;
  font-size: 0.8rem;
}

.topbar-meta #resultCount {
  margin-right: auto;
  font-weight: 600;
  color: #4b5563;
}

.mini-btn {
  border: 1px solid #d4dbe7;
  border-radius: 9px;
  background: #fff;
  color: #374151;
  font: inherit;
  font-size: 0.76rem;
  padding: 5px 8px;
  cursor: pointer;
}

.mini-btn:hover {
  background: #f8fafc;
}

.mini-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.manage-toggle {
  color: #4b5563;
  background: #fff;
  border-color: #d4dbe7;
  font-weight: 620;
}

.manage-toggle.active {
  color: #fff;
  border-color: #1e4ed8;
  background: #2f5ee6;
}

.mini-btn.danger {
  color: #b42318;
  border-color: #f2c7cf;
  background: #fff5f6;
}

.sync-status {
  font-size: 0.78rem;
  border-radius: 999px;
  padding: 2px 8px;
  color: #0f5132;
  background: #d1fae5;
}

.sync-status.offline {
  color: #7f1d1d;
  background: #fee2e2;
}

.list-message {
  min-height: 1.1em;
  margin: 8px 0 0;
  font-size: 0.84rem;
}

.list-message.success {
  color: var(--success);
}

.list-message.error {
  color: var(--danger);
}

.mobile-quick-cats {
  display: none;
  margin-top: 10px;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.mobile-quick-cats .chip {
  border: 1px solid #d8e2f1;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  padding: 6px 10px;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
}

.mobile-quick-cats .chip.active {
  border-color: #8db5ff;
  background: #eaf2ff;
  color: #1849a9;
}

.batch-panel {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid #dde6f5;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.batch-panel.hidden {
  display: none;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  color: #334155;
}

.selected-count {
  font-size: 0.84rem;
  color: #64748b;
}

.batch-input {
  min-width: 180px;
  border: 1px solid #d4deef;
  border-radius: 9px;
  padding: 6px 8px;
  font: inherit;
}

.batch-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 122, 248, 0.12);
}

.table-wrap {
  margin-top: 12px;
  border: 1px solid #dde6f5;
  border-radius: 12px;
  background: #fff;
  overflow: auto;
}

.table-wrap.hidden {
  display: none;
}

.bookmark-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.bookmark-table th,
.bookmark-table td {
  border-bottom: 1px solid #edf1f8;
  text-align: left;
  padding: 10px;
  vertical-align: middle;
  font-size: 0.86rem;
}

.bookmark-table th {
  background: #f8fbff;
  color: #334155;
  font-weight: 700;
}

.bookmark-table tr:hover td {
  background: #f9fbff;
}

.bookmark-table .c-select {
  width: 66px;
}

.bookmark-table .c-time {
  width: 132px;
}

.bookmark-table .c-action {
  width: 160px;
}

.table-title {
  font-weight: 700;
  color: #1f2937;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-url {
  color: #1d4ed8;
  max-width: 280px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.table-url:hover {
  text-decoration: underline;
}

.table-category {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.78rem;
}

.table-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.table-tags .tag {
  font-size: 0.72rem;
}

.bookmark-sections {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-group {
  padding-top: 2px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}

.section-head h3 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  color: #0f172a;
}

.section-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-edit-btn {
  border: 1px solid #d7dfea;
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font: inherit;
  font-size: 0.74rem;
  padding: 3px 8px;
  cursor: pointer;
}

.section-edit-btn:hover {
  background: #f5f8ff;
}

.section-hidden .section-head h3 {
  color: #6b7280;
}

.section-head span {
  color: #9aa3b5;
  font-size: 0.78rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.site-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 13px;
  border: 1px solid #e3e8f1;
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

.site-card:hover {
  border-color: #d4deee;
}

.site-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.card-main {
  display: flex;
  gap: 10px;
  align-items: center;
}

.site-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  object-fit: contain;
  padding: 5px;
  flex-shrink: 0;
}

.site-info {
  min-width: 0;
}

.site-title {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.25;
  font-weight: 800;
  color: var(--text-strong);
  max-height: 2.5em;
  overflow: hidden;
}

.site-desc {
  margin-top: 4px;
  font-size: 0.8rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-url {
  margin-top: 2px;
  font-size: 0.72rem;
  color: #a0aabc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 16px;
}

.tag {
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 0.67rem;
  color: #7f8ba1;
  background: #f1f5fb;
}

.card-actions {
  display: flex;
  gap: 5px;
}

.card-action-btn {
  flex: 1;
  border: 1px solid #d8dfec;
  border-radius: 9px;
  padding: 5px 6px;
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  color: #374151;
}

.card-action-btn:hover {
  background: #f6f8fc;
}

.card-action-btn.danger {
  color: var(--danger);
  border-color: #f2ccd2;
  background: var(--danger-bg);
}

.empty-state {
  margin-top: 16px;
  border: 1px dashed #c7d3e8;
  border-radius: var(--radius-md);
  background: #fff;
  padding: 32px 18px;
  text-align: center;
  color: #667085;
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: #1f2937;
}

.context-menu {
  position: fixed;
  z-index: 60;
  min-width: 156px;
  border: 1px solid #dde3ef;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.16);
  padding: 6px;
}

.ctx-item {
  width: 100%;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #1f2937;
  text-align: left;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.ctx-item:hover {
  background: #f3f6fc;
}

.ctx-item.danger {
  color: #c3283e;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 12, 22, 0.45);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 14px;
  z-index: 40;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 28px);
  overflow: auto;
  border-radius: 16px;
  border: 1px solid #dde4f2;
  background: #fff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.25);
  padding: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #d6dde9;
  background: #fff;
  font-size: 1.16rem;
  line-height: 1;
  cursor: pointer;
}

.bookmark-form {
  display: grid;
  gap: 10px;
}

.bookmark-form label {
  font-size: 0.88rem;
  color: #4b5563;
  font-weight: 620;
}

.bookmark-form input {
  border: 1px solid #cdd8ea;
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  color: #111827;
}

.bookmark-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 122, 248, 0.14);
}

.form-actions {
  margin-top: 4px;
  display: flex;
  gap: 8px;
}

.modal-cancel-btn {
  color: #4b5563;
}

.form-message {
  margin: 10px 0 0;
  min-height: 1.2em;
  font-size: 0.88rem;
}

.form-message.success {
  color: var(--success);
}

.form-message.error {
  color: var(--danger);
}

.qr-card {
  width: min(360px, 100%);
}

.qr-wrap {
  text-align: center;
}

.qr-image {
  width: 220px;
  height: 220px;
  max-width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  padding: 6px;
}

.qr-text {
  margin: 10px 0 0;
  color: #6b7280;
  font-size: 0.82rem;
  word-break: break-all;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid #e6e9f0;
    padding: 14px;
  }

  .category-list {
    max-height: 220px;
  }

  .main-content {
    padding: 12px;
  }

  .section-head h3 {
    font-size: 1.5rem;
  }
}

@media (max-width: 640px) {
  .topbar-meta {
    flex-wrap: wrap;
  }

  .side-actions {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .mobile-quick-cats {
    display: flex;
  }
}
