:root {
  --bg: #edf1ee;
  --surface: #ffffff;
  --surface-strong: #f7faf7;
  --ink: #17221d;
  --muted: #61716b;
  --line: #cbd8d2;
  --field: #eef5f2;
  --teal: #087f75;
  --teal-dark: #075f59;
  --rust: #b64a35;
  --gold: #c58a16;
  --sky: #dcebf2;
  --leaf: #dceadc;
  --shadow: 0 18px 48px rgba(23, 34, 29, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "LXGW WenKai Screen", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(135deg, rgba(220, 235, 242, 0.95), rgba(220, 234, 220, 0.92) 42%, rgba(245, 238, 225, 0.88)),
    repeating-linear-gradient(90deg, rgba(8, 127, 117, 0.06) 0 1px, transparent 1px 46px);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  width: calc(100% - 40px);
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.4vw, 2.35rem);
  line-height: 1;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(23, 34, 29, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(23, 34, 29, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--teal-dark);
  text-decoration: none;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--teal);
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width, 288px) 6px 1fr;
  gap: 0;
  align-items: start;
}

.resizer {
  width: 6px;
  cursor: col-resize;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  align-self: stretch;
}

.resizer::before {
  content: "";
  position: absolute;
  left: -7px;
  right: -7px;
  top: 0;
  bottom: 0;
}

.resizer::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: transparent;
  transition: background 0.2s;
}

.resizer:hover::after,
.resizer.active::after {
  background: var(--teal);
}

.sidebar,
.content-area {
  min-width: 0;
  overflow: hidden;
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 120px);
}

.sidebar .panel:last-child {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel,
.search-band,
.result-header,
.empty-state {
  border: 1px solid rgba(23, 34, 29, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel h2,
.result-header h2,
.empty-state h2 {
  margin: 0;
  font-size: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.stats-grid div {
  min-width: 0;
  padding: 12px 8px;
  border-radius: 8px;
  background: var(--surface-strong);
  text-align: center;
}

.stats-grid strong {
  display: block;
  font-size: 1.35rem;
  color: var(--teal-dark);
}

.stats-grid span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--teal-dark);
}

.category-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  overflow-y: scroll;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
  scrollbar-color: var(--line) transparent;
}

.category-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.category-chip[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--leaf);
}

.category-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.category-count {
  flex-shrink: 0;
  color: var(--muted);
}

.sidebar-tree-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  font-size: 0.9rem;
}

.sidebar-tree-node:hover {
  background: var(--field);
}

.sidebar-tree-folder {
  color: var(--muted);
  font-weight: 500;
}

.sidebar-tree-leaf.active {
  background: var(--leaf);
  color: var(--teal-dark);
}

.sidebar-tree-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sidebar-tree-count {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebar-tree-sub {
  /* indentation handled by tree-node padding */
}

.content-area {
  display: grid;
  gap: 16px;
}

.search-band {
  padding: 16px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.search-symbol {
  flex: 0 0 auto;
  color: var(--rust);
  font-size: 1.35rem;
  line-height: 1;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search-box input::placeholder {
  color: #7d8b86;
}

.primary-button {
  min-width: 86px;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #ffffff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--teal-dark);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.select-label {
  color: var(--muted);
}

select {
  min-height: 36px;
  padding: 6px 34px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.result-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
  padding: 14px 16px;
  box-shadow: none;
}

.result-header p {
  margin: 0;
  color: var(--muted);
}

.public-scope-note {
  grid-column: 1 / -1;
  font-size: 0.9rem;
}

.bookmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.load-more-row {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.bookmark-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(23, 34, 29, 0.14);
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px rgba(23, 34, 29, 0.08);
}

.card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.bookmark-card h3 {
  margin: 0 0 6px;
  font-size: 1.08rem;
  line-height: 1.35;
}

.bookmark-url {
  display: block;
  overflow: hidden;
  color: var(--teal-dark);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-link {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.copy-link.copied {
  background: var(--leaf);
  border-color: var(--teal);
}

.open-link {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sky);
  color: var(--ink);
  text-decoration: none;
}

mark {
  background: #fae7d3;
  color: #744224;
  border-radius: 3px;
  padding: 0 2px;
}

.description {
  min-height: 44px;
  margin: 0;
  color: #34413c;
  line-height: 1.55;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--field);
  color: #3d4b46;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.tag.category {
  background: var(--leaf);
  color: var(--teal-dark);
}

.tag.keyword {
  background: #fae7d3;
  color: #744224;
}

.bookmark-card footer {
  padding-top: 4px;
  border-top: 1px solid rgba(23, 34, 29, 0.1);
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-state {
  padding: 36px 18px;
  text-align: center;
  box-shadow: none;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
}

.sidebar-toggle {
  display: none;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .resizer {
    display: none;
  }

  .sidebar {
    position: static;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    max-height: none;
  }

  .sidebar .panel:last-child {
    display: block;
    overflow: visible;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .category-list {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    overflow-y: visible;
    flex: auto;
    scrollbar-width: auto;
  }

  .category-list.collapsed {
    display: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }

  .result-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .bookmark-grid {
    grid-template-columns: 1fr;
  }
}
