:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #eef3f5;
  --text: #1c2430;
  --muted: #637083;
  --line: #dce3e8;
  --accent: #0f766e;
  --accent-strong: #0b5f58;
  --accent-soft: #d8f2ee;
  --warning: #b45309;
  --warning-soft: #fff1d6;
  --danger: #b42318;
  --shadow: 0 12px 34px rgba(28, 36, 48, 0.09);
  --radius: 8px;
  --header-h: 72px;
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

body.dark {
  color-scheme: dark;
  --bg: #151716;
  --surface: #1e2220;
  --surface-muted: #252b28;
  --text: #edf2ee;
  --muted: #aab6af;
  --line: #333b37;
  --accent: #42b8a8;
  --accent-strong: #7dd9cc;
  --accent-soft: rgba(66, 184, 168, 0.15);
  --warning: #f6b35d;
  --warning-soft: rgba(246, 179, 93, 0.14);
  --danger: #ff8a80;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 270px),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(240px, 1fr) 44px;
  gap: 16px;
  align-items: center;
  height: var(--header-h);
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, transparent), transparent),
    var(--surface);
  color: var(--accent-strong);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 17px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.search-wrap {
  position: relative;
  min-width: 0;
}

.search-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-wrap input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--surface-muted);
  color: var(--text);
}

.search-wrap input:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.icon-button:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent-strong);
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 48px);
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.side-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.category-nav {
  display: grid;
  gap: 8px;
}

.category-button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.category-button:hover,
.category-button.active {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: var(--accent-soft);
}

.category-button svg {
  width: 18px;
  height: 18px;
  color: var(--accent-strong);
}

.category-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-button small {
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  text-align: center;
}

.content {
  min-width: 0;
}

.summary {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 10px;
}

.stats div {
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.stats strong,
.stats span {
  display: block;
}

.stats strong {
  font-size: 22px;
}

.stats span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.segment {
  min-width: 74px;
  min-height: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: var(--accent);
  color: #ffffff;
}

.active-meta {
  color: var(--muted);
  font-size: 14px;
}

.sections {
  display: grid;
  gap: 26px;
}

.tool-section {
  scroll-margin-top: calc(var(--header-h) + 18px);
}

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

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.section-title svg {
  width: 20px;
  height: 20px;
  color: var(--accent-strong);
}

.section-title h2 {
  margin: 0;
  font-size: 19px;
}

.section-count {
  color: var(--muted);
  font-size: 13px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.tool-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 178px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(28, 36, 48, 0.06);
}

.tool-card:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  transform: translateY(-1px);
}

.tool-card.is-empty {
  border-style: dashed;
}

.card-top {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 34px;
  gap: 12px;
  align-items: center;
}

.tool-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tool-icon svg {
  width: 20px;
  height: 20px;
}

.tool-card h3 {
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-card .url {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--muted);
}

.favorite-button.active {
  border-color: color-mix(in srgb, var(--warning) 40%, var(--line));
  background: var(--warning-soft);
  color: var(--warning);
}

.favorite-button svg {
  width: 17px;
  height: 17px;
}

.description {
  margin: 14px 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.tag {
  max-width: 100%;
  padding: 4px 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
}

.open-link svg {
  width: 16px;
  height: 16px;
}

.open-link.disabled {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--muted);
  pointer-events: none;
}

.status {
  color: var(--muted);
  font-size: 12px;
}

.status.empty {
  color: var(--danger);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 36px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state svg {
  width: 42px;
  height: 42px;
  margin-bottom: 12px;
  color: var(--accent-strong);
}

.empty-state h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: minmax(160px, 1fr) 44px;
    height: auto;
  }

  .search-wrap {
    grid-column: 1 / -1;
    order: 3;
  }

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

  .sidebar {
    position: static;
    max-height: none;
  }

  .category-nav {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar,
  .layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .summary,
  .controls {
    display: grid;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
  }

  h1 {
    font-size: 22px;
  }
}
