:root {
  --bg: #f4f4f5;
  --panel: #ffffff;
  --text: #111111;
  --muted: #6b7280;
  --line: #d8d8dc;
  --line-soft: #ececef;
  --side: #e7e7ea;
  --side-soft: #f1f1f3;
  --hover: #eeeeef;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
  line-height: 1.35;
}

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

.layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  color: #18181b;
  background: var(--side);
  border-right: 1px solid #ccccd1;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding: 0 6px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  overflow: hidden;
  background: #ffffff;
  border-radius: 9px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-subtitle {
  margin-top: 1px;
  color: #6b7280;
  font-size: 12px;
}

.side-label {
  margin: 0 6px 9px;
  color: #71717a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.category-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.category-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  color: #3f3f46;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  transition: 150ms ease;
}

.category-link:hover,
.category-link.active {
  color: #111111;
  background: var(--side-soft);
  border-color: #c8c8ce;
}

.category-count {
  min-width: 22px;
  padding: 1px 6px;
  color: #ffffff;
  background: #18181b;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.content {
  min-width: 0;
  padding: 26px clamp(18px, 3vw, 38px) 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.search-form {
  display: grid;
  grid-template-columns: auto minmax(220px, 520px) 42px;
  align-items: center;
  min-width: min(680px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-form input {
  height: 40px;
  color: #18181b;
  background: transparent;
  border: 0;
  outline: none;
  font: inherit;
  font-size: 13px;
}

.search-engine-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 4px;
  border-right: 1px solid var(--line-soft);
  background: #fafafa;
}

.search-engine-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 8px;
  color: #52525b;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  transition: 150ms ease;
}

.search-engine-btn:hover {
  color: #18181b;
  background: #eeeeef;
}

.search-engine-btn.active {
  color: #111111;
  background: #ffffff;
  border-color: #d8d8dc;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.search-engine-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}

.search-engine-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
}

.search-form input {
  min-width: 0;
  padding: 0 12px;
}

.search-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 40px;
  color: #111111;
  background: #ffffff;
  border: 0;
  border-left: 1px solid var(--line-soft);
  cursor: pointer;
}

.search-btn:hover {
  background: #f4f4f5;
}

.search-btn svg {
  width: 16px;
  height: 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.05;
  letter-spacing: -0.055em;
}

.summary {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.top-actions,
.section-actions,
.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.top-actions {
  justify-content: flex-end;
}

.admin-password {
  width: 132px;
  height: 30px;
  padding: 0 9px;
  color: #18181b;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
}

.admin-password:focus {
  border-color: #18181b;
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  color: #18181b;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  transition: 150ms ease;
}

.btn:hover {
  background: var(--hover);
  border-color: #a1a1aa;
}

.btn.primary {
  color: #ffffff;
  background: #111111;
  border-color: #111111;
}

.btn.primary:hover {
  background: #333333;
}

.btn.danger {
  color: #4b1111;
}

.btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}

.hidden-file {
  display: none;
}

.section {
  scroll-margin-top: 18px;
  margin-top: 26px;
}

.section:first-of-type {
  margin-top: 0;
}

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

.section-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

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

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

.site-card {
  display: grid;
  grid-template-columns: 22px 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.site-link {
  display: grid;
  grid-column: 2 / 4;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.site-card:hover {
  transform: translateY(-2px);
  background: #fbfbfb;
  border-color: #9f9fa4;
}

.item-check {
  width: 16px;
  height: 16px;
  accent-color: #111111;
  cursor: pointer;
}

.icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #ffffff;
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.favicon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.card-body {
  min-width: 0;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 800;
}

.card-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.external {
  color: #9ca3af;
  line-height: 0;
}

.external svg {
  width: 12px;
  height: 12px;
}

.card-desc {
  display: none;
  margin: 0 0 5px;
  overflow: hidden;
  color: #5f6368;
  font-size: 11px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-url {
  overflow: hidden;
  color: #8a8f98;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  grid-column: 4;
  margin-top: 0;
  flex-wrap: nowrap;
}

.batch-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -10px 0 18px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow);
}

.batch-bar.active {
  display: flex;
}

.batch-info {
  color: #3f3f46;
  font-size: 13px;
  font-weight: 750;
}

.batch-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.card-actions .btn {
  width: 24px;
  height: 22px;
  padding: 0;
  font-size: 11px;
  border-radius: 8px;
}

.card-actions .btn svg {
  width: 13px;
  height: 13px;
}

.empty-section {
  padding: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.state {
  display: grid;
  place-items: center;
  min-height: 45vh;
  color: var(--muted);
  font-size: 14px;
}

.dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.dialog::backdrop {
  background: rgba(17, 17, 17, 0.36);
  backdrop-filter: blur(2px);
}

.dialog-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.dialog-title {
  margin: 0;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: -0.04em;
}

.dialog-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.dialog-close {
  width: 30px;
  height: 30px;
  padding: 0;
  color: #52525b;
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 9px;
  cursor: pointer;
}

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

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: #3f3f46;
  font-size: 12px;
  font-weight: 750;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  color: #18181b;
  background: #fafafa;
  border: 1px solid #d4d4d8;
  border-radius: 10px;
  outline: none;
  font: inherit;
  font-size: 13px;
  transition: 150ms ease;
}

.field textarea {
  min-height: 70px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  background: #ffffff;
  border-color: #18181b;
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  place-items: center;
  background: rgba(244, 244, 245, 0.72);
  backdrop-filter: blur(2px);
}

.loading-overlay.active {
  display: grid;
}

.loading-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 14px 16px;
  color: #18181b;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.16);
  font-size: 13px;
  font-weight: 750;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d4d4d8;
  border-top-color: #111111;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-form {
    grid-template-columns: 1fr 40px;
    width: 100%;
    min-width: 0;
  }

  .search-engine-switch {
    grid-column: 1 / -1;
    justify-content: space-between;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .search-engine-btn {
    flex: 1;
    justify-content: center;
  }

  .summary {
    white-space: normal;
  }
}
