:root {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --card: rgba(22, 27, 34, 0.6);
  --card-hover: rgba(22, 27, 34, 0.8);
  --muted: #8b949e;
  --txt: #c9d1d9;
  --txt-heading: #f0f6fc;
  --txt-very-muted: #6e7681;
  --accent: #58a6ff;
  --accent-2: #4a8fd9;
  --accent-glow: rgba(88, 166, 255, 0.2);
  --border: #30363d;
  --shadow: 0 10px 35px rgba(0, 0, 0, 0.8);
  --radius: 4px;
  --header-height: 72px;
  --sidebar-width: 280px;
  --graph-padding-x: 40px;
}

body.theme-codex {
  --bg: #f4f6fb;
  --bg-secondary: #ffffff;
  --card: #ffffff;
  --card-hover: #f9fbff;
  --muted: #4b5565;
  --txt: #0f172a;
  --txt-heading: #020617;
  --txt-very-muted: #94a3b8;
  --accent: #10b981;
  --accent-2: #059669;
  --accent-glow: rgba(16, 185, 129, 0.18);
  --border: #d9e3f5;
  --shadow: 0 30px 60px rgba(15, 23, 42, 0.08);
  --sidebar-width: 310px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

body.theme-codex {
  font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 12% 20%, rgba(16, 185, 129, 0.16), transparent 40%),
    radial-gradient(circle at 82% 8%, rgba(34, 197, 94, 0.12), transparent 45%),
    #f4f6fb;
  color: var(--txt);
}

/* ===== HEADER ===== */
.site-header {
  backdrop-filter: blur(20px);
  background: rgba(10, 14, 20, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  height: var(--header-height);
  padding: 0 32px;
  display: flex;
  align-items: center;
}
.site-header .header-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  width: 100%;
}

.site-header .title h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--accent);
}

.site-header .title .subtitle {
  margin: 4px 0 0 0;
  font-size: 14px;
  color: var(--muted);
}

.site-header .nav-menu {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.site-header .nav-btn {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.site-header .nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
  color: var(--txt);
}

.site-header .nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

body.theme-codex .site-header {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.07);
}

body.theme-codex .site-header .title h1 {
  font-size: 30px;
  color: #0f172a;
}

body.theme-codex .site-header .title .subtitle {
  color: #475467;
}

body.theme-codex .site-header .nav-btn {
  background: transparent;
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: #475467;
  border-radius: 999px;
  padding: 10px 24px;
}

body.theme-codex .site-header .nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(16, 185, 129, 0.08);
}

body.theme-codex .site-header .nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.35);
}


/* ===== BASKET WIDGET (Floating) ===== */
.basket-widget-floating {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  width: 300px;
  max-height: 500px;
  overflow: hidden;
  box-shadow: none;
  transition: all 0.3s ease;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
}

.basket-widget-floating.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.basket-widget-floating.has-items {
  border-color: var(--accent);
}

.basket-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: rgba(110, 177, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.basket-icon {
  font-size: 20px;
}

.basket-title {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
}

.basket-count {
  background: var(--accent);
  color: var(--bg);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.basket-content {
  padding: 12px;
}

.basket-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.basket-empty {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 13px;
}

.basket-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  margin-bottom: 6px;
  transition: background 0.2s ease;
}

.basket-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.basket-item-name {
  flex: 1;
  font-size: 13px;
  color: var(--txt);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.basket-remove-btn {
  background: rgba(255, 100, 100, 0.2);
  border: none;
  color: #ff6b6b;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
}

.basket-remove-btn:hover {
  background: rgba(255, 100, 100, 0.4);
  transform: scale(1.1);
}

.basket-actions {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-2);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--txt);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ===== SIDEBAR LAYOUT ===== */
body[data-layout="sidebar"] {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body[data-layout="sidebar"] .site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

body[data-layout="sidebar"] .sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  z-index: 90;
}

body[data-layout="sidebar"] #mainContent {
  margin-left: var(--sidebar-width);
  margin-top: calc(var(--header-height) + 8px);
  flex: 1;
}

body.theme-codex[data-layout="sidebar"] #mainContent {
  margin-left: 310px;
  margin-right: 40px;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  padding-top: 0;
}

.sidebar::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

body.theme-codex .sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #f7fff9 55%, #eeffef 100%);
  border-right: 1px solid var(--border);
  box-shadow: 18px 0 45px rgba(15, 23, 42, 0.05);
}

body.theme-codex .sidebar-search {
  padding: 20px 24px 12px;
  border-bottom: none;
}

body.theme-codex .sidebar-search input {
  background: #edf2ed;
  border: 1px solid transparent;
  color: var(--txt);
  border-radius: 12px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

body.theme-codex .sidebar-search input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

body.theme-codex .sidebar-header {
  padding: 12px 24px 8px;
  border-bottom: none;
}

body.theme-codex .sidebar-home-link {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--txt-heading);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

body.theme-codex .sidebar-home-link:hover {
  background: rgba(16, 185, 129, 0.12);
}

body.theme-codex .sidebar-section-title {
  color: #94a3b8;
  letter-spacing: 0.2em;
  font-size: 11px;
  padding: 16px 28px 6px;
}

body.theme-codex .sidebar-category {
  border-bottom: none;
  padding: 0 16px 8px;
}

body.theme-codex .sidebar-category-header {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.8);
  color: #0f172a;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

body.theme-codex .sidebar-category-header:hover {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.1);
}

body.theme-codex .sidebar-category-icon {
  color: #94a3b8;
}

body.theme-codex .sidebar-groups {
  padding-left: 0;
  margin: 6px 6px 0;
  border-left: 2px solid rgba(16, 185, 129, 0.16);
}

body.theme-codex .sidebar-group {
  border-left: none;
  border-radius: 12px;
  margin: 4px 0;
  padding: 8px 14px;
  color: #475467;
  font-weight: 500;
}

body.theme-codex .sidebar-group:hover {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent);
}

body.theme-codex .sidebar-group.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.35);
}

body.theme-codex .sidebar-items {
  padding-left: 0;
  margin: 4px 0 0 0;
}

body.theme-codex .sidebar-item {
  border-left: none;
  border-radius: 10px;
  padding: 6px 14px;
  color: #5b6475;
}

body.theme-codex .sidebar-item:hover {
  background: rgba(16, 185, 129, 0.1);
  padding-left: 18px;
}

body.theme-codex .sidebar-item.active {
  background: rgba(16, 185, 129, 0.16);
  color: #0f172a;
  font-weight: 600;
}

.sidebar-search {
  padding: 16px 16px 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-height);
  background: var(--bg-secondary);
  z-index: 10;
}

.sidebar-search input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--txt);
  font-size: 14px;
  transition: all 0.2s ease;
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-home-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--txt-heading);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 8px;
}

.sidebar-home-link:hover {
  background: rgba(88, 166, 255, 0.1);
  color: var(--accent);
}

.home-icon {
  font-size: 18px;
}

.sidebar-section-title {
  padding: 12px 24px 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-category {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: transparent;
  border: none;
  color: var(--txt-heading);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s ease;
}

.sidebar-category-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-category-icon {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.sidebar-category.expanded .sidebar-category-icon {
  transform: rotate(90deg);
}

.sidebar-groups {
  display: none;
  padding-left: 16px;
}

.sidebar-category.expanded .sidebar-groups {
  display: block;
}

.sidebar-group {
  padding: 10px 24px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 2px solid transparent;
}

.sidebar-group:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--txt);
  border-left-color: var(--accent);
}

.sidebar-group.active,
.sidebar-group.selected {
  background: rgba(88, 166, 255, 0.1);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.sidebar-items {
  display: none;
  padding-left: 16px;
  margin-top: 4px;
}

.sidebar-group.expanded .sidebar-items {
  display: block;
}

.sidebar-item {
  padding: 6px 24px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 2px solid transparent;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--txt);
  padding-left: 28px;
}

.sidebar-item.active {
  background: rgba(88, 166, 255, 0.08);
  color: var(--accent);
  font-weight: 500;
}

/* ===== MAIN CONTENT ===== */
main, #mainContent {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 40px 120px 40px;
  min-height: 100vh;
}

body.theme-codex #mainContent {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(237, 243, 255, 0.92) 55%, rgba(230, 249, 255, 0.9) 100%);
  border: 1px solid var(--border);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 52px 60px 120px 60px;
  position: relative;
  overflow: hidden;
}

body.theme-codex #mainContent::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 25% 20%, rgba(16, 185, 129, 0.15), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(59, 130, 246, 0.15), transparent 40%);
  opacity: 0.7;
  pointer-events: none;
}

body.theme-codex #mainContent > * {
  position: relative;
  z-index: 1;
}

body[data-view="graph"] #mainContent {
  padding: 32px 0 120px 0;
  max-width: none;
}

body.theme-codex[data-view="graph"] #mainContent {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 32px 0 120px 0;
  margin-right: 0;
  overflow: visible;
}

body.theme-codex[data-view="graph"] #mainContent::before {
  content: none;
}

/* ===== CLUSTERS GRID (Landing) ===== */
.clusters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  grid-auto-flow: dense;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.cluster-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 28px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

body.theme-codex .clusters-grid {
  gap: 32px;
}

body.theme-codex .cluster-card {
  border-radius: 26px;
  border: 1px solid var(--border);
  padding: 32px;
  background: linear-gradient(180deg, #ffffff 0%, #f4fff8 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

body.theme-codex .cluster-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--accent), #34d399);
  opacity: 0.85;
}

body.theme-codex .cluster-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 25px 55px rgba(15, 23, 42, 0.15);
}

body.theme-codex .cluster-icon {
  color: var(--accent);
  filter: drop-shadow(0 8px 20px rgba(16, 185, 129, 0.35));
}

body.theme-codex .cluster-title {
  color: var(--txt-heading);
  font-size: 24px;
}

body.theme-codex .cluster-count {
  background: rgba(16, 185, 129, 0.12);
  color: #0f172a;
  border-radius: 999px;
  display: inline-flex;
  padding: 4px 16px;
  font-size: 13px;
}

body.theme-codex .cluster-preview {
  color: #475467;
}

body.theme-codex .cluster-explore-btn {
  border-radius: 999px;
  background: linear-gradient(120deg, var(--accent), #22c55e);
  color: #fff;
  border: none;
  font-weight: 600;
  padding: 10px 20px;
  box-shadow: 0 15px 30px rgba(16, 185, 129, 0.25);
  width: auto;
  align-self: flex-start;
}

.cluster-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.cluster-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: inline-block;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.cluster-title {
  margin: 0 0 8px 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--txt);
}

.cluster-count {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.cluster-preview {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.6;
  min-height: 40px;
}

.cluster-explore-btn {
  background: rgba(110, 177, 255, 0.12);
  border: 1px solid rgba(110, 177, 255, 0.3);
  color: var(--accent);
  padding: 10px 20px;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
}

.cluster-explore-btn:hover {
  background: rgba(110, 177, 255, 0.2);
  border-color: var(--accent);
}

/* ===== CLUSTER DETAIL VIEW ===== */
.cluster-detail {
  animation: slideIn 0.4s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.cluster-header {
  margin-bottom: 48px;
}

.back-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--txt);
  padding: 10px 18px;
  border-radius: 3px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 24px;
  transition: all 0.2s ease;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}

.cluster-header h1 {
  margin: 0 0 8px 0;
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
}

.cluster-subtitle {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

body.theme-codex .cluster-header {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 24px 28px;
  box-shadow: var(--shadow);
}

body.theme-codex .back-btn {
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(16, 185, 129, 0.12);
  color: #0f172a;
  font-weight: 600;
  padding: 10px 20px;
}

body.theme-codex .cluster-header h1 {
  color: #0f172a;
}

body.theme-codex .cluster-subtitle {
  color: #475467;
}

.tool-section {
  margin-bottom: 48px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--txt);
  margin: 0 0 20px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
}

body.theme-codex .section-title {
  border-bottom: 2px solid rgba(15, 23, 42, 0.08);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0f172a;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  grid-auto-flow: dense;
}

.tool-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
  padding: 18px;
  transition: all 0.2s ease;
  position: relative;
  cursor: pointer;
}

body.theme-codex .tool-card {
  border-radius: 22px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 24px;
  background: #fff;
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.08);
}

body.theme-codex .tool-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 25px 50px rgba(15, 23, 42, 0.15);
}

body.theme-codex .tool-card.in-basket {
  background: rgba(16, 185, 129, 0.08);
  border-color: var(--accent);
}

body.theme-codex .tool-card.popular {
  border-color: #22c55e;
  box-shadow: 0 25px 55px rgba(34, 197, 94, 0.25);
}

body.theme-codex .tool-name {
  color: #0f172a;
  letter-spacing: -0.01em;
}

body.theme-codex .tool-summary {
  color: #475467;
}

body.theme-codex .tool-tags {
  gap: 8px;
}

body.theme-codex .tag {
  background: rgba(16, 185, 129, 0.12);
  border: none;
  color: #0369a1;
  text-transform: none;
  letter-spacing: 0;
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.tool-card.in-basket {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.05);
}

.tool-card.popular {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.03);
}

.tool-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.tool-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--txt);
  transition: color 0.2s ease;
  flex: 1;
}

.add-to-basket-btn {
  background: var(--accent);
  border: none;
  color: var(--bg);
  width: 32px;
  height: 32px;
  border-radius: 3px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.add-to-basket-btn:hover {
  background: var(--accent-2);
}

.tool-summary {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px 0;
  line-height: 1.5;
}

.tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  background: rgba(110, 177, 255, 0.15);
  border: 1px solid rgba(110, 177, 255, 0.3);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== GROUP ITEMS VIEW ===== */
.group-items-view {
  animation: slideIn 0.4s ease;
}

.group-items-header {
  margin-bottom: 32px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 8px;
}

.breadcrumb-category {
  color: var(--accent);
  font-weight: 600;
}

.breadcrumb-separator {
  color: var(--muted);
}

.breadcrumb-group {
  color: var(--txt-heading);
  font-weight: 600;
  font-size: 18px;
}

.group-items-count {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.group-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.item-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.item-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.item-name {
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--txt-heading);
}

.item-summary {
  margin: 0 0 16px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Codex theme overrides for group items view */
body.theme-codex .group-items-view {
  background: transparent;
}

body.theme-codex .breadcrumb-category {
  color: var(--accent);
}

body.theme-codex .breadcrumb-group {
  color: #0f172a;
}

body.theme-codex .item-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

body.theme-codex .item-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
  border-color: var(--accent);
}

body.theme-codex .item-name {
  color: #0f172a;
}

body.theme-codex .item-summary {
  color: #475467;
}

/* ===== COMPARISON VIEW ===== */
.comparison-view {
  animation: fadeIn 0.5s ease;
}

.comparison-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.comparison-header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
}

.clear-basket-btn {
  background: rgba(255, 100, 100, 0.12);
  border: 1px solid rgba(255, 100, 100, 0.3);
  color: #ff6b6b;
  padding: 10px 20px;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.clear-basket-btn:hover {
  background: rgba(255, 100, 100, 0.2);
  border-color: #ff6b6b;
}

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

.comparison-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 24px;
}

body.theme-codex .comparison-card {
  border-radius: 22px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.08);
}

body.theme-codex .comparison-card-header {
  border-bottom: 2px solid rgba(15, 23, 42, 0.08);
}

body.theme-codex .comparison-field strong {
  color: #0f172a;
  letter-spacing: 0.08em;
}

body.theme-codex .comparison-field p,
body.theme-codex .comparison-field span {
  color: #475467;
}

.comparison-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
}

.comparison-card-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  flex: 1;
}

.remove-from-basket {
  background: rgba(255, 100, 100, 0.2);
  border: none;
  color: #ff6b6b;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-from-basket:hover {
  background: rgba(255, 100, 100, 0.4);
  transform: scale(1.1);
}

.comparison-field {
  margin-bottom: 16px;
}

.comparison-field strong {
  display: block;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.comparison-field p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.comparison-field span {
  font-size: 14px;
  color: var(--txt);
}

.comparison-link {
  display: block;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 6px;
  word-break: break-all;
  transition: color 0.2s ease;
}

.comparison-link:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

/* ===== FAQs VIEW ===== */
.faqs-view {
  animation: fadeIn 0.5s ease;
}

.faqs-container {
  max-width: 900px;
  margin: 0 auto;
}

.faqs-header {
  margin-bottom: 48px;
  text-align: center;
}

.faqs-header h1 {
  margin: 0 0 12px 0;
  font-size: 42px;
  font-weight: 800;
  color: var(--accent);
}

.faqs-subtitle {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.faq-item {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
  padding: 28px;
  transition: all 0.2s ease;
}

body.theme-codex .faq-item,
body.theme-codex .faq-accordion-item,
body.theme-codex .content-item-card,
body.theme-codex .basket-widget-floating,
body.theme-codex .comparison-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 15px 40px rgba(15, 23, 42, 0.08);
}

body.theme-codex .faq-item:hover,
body.theme-codex .faq-accordion-item:hover,
body.theme-codex .content-item-card:hover {
  box-shadow: 0 25px 55px rgba(15, 23, 42, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}

.faq-item:hover {
  border-color: var(--accent);
}

.faq-item h3 {
  margin: 0 0 12px 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--txt-heading);
}

.faq-item p {
  margin: 0 0 12px 0;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.7;
}

.faq-item p:last-child {
  margin-bottom: 0;
}

.faq-item kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: monospace;
  font-size: 13px;
  color: var(--accent);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* ===== FAQ ACCORDION ===== */
.faq-accordion-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.faq-accordion-item {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s ease;
}

.faq-accordion-item:hover {
  border-color: var(--accent);
}

.faq-accordion-item.active {
  border-color: var(--accent);
}

.faq-accordion-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: transparent;
  border: none;
  color: var(--txt-heading);
  font-size: 18px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.faq-accordion-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.faq-accordion-header:hover .faq-question {
  color: var(--accent);
}

.faq-question {
  flex: 1;
  transition: color 0.2s ease;
}

.faq-accordion-icon {
  font-size: 24px;
  font-weight: 300;
  color: var(--accent);
  min-width: 30px;
  text-align: center;
  transition: transform 0.3s ease;
}

.faq-accordion-item.active .faq-accordion-icon {
  transform: rotate(180deg);
}

.faq-accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.faq-accordion-body {
  padding: 0 24px 24px 24px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.faq-accordion-body p {
  margin: 0 0 16px 0;
}

.faq-accordion-body p:last-child {
  margin-bottom: 0;
}

.faq-accordion-body strong {
  color: var(--txt-heading);
  font-weight: 600;
}

.faq-accordion-body ul,
.faq-accordion-body ol {
  margin: 12px 0;
  padding-left: 24px;
}

.faq-accordion-body li {
  margin-bottom: 8px;
}

.faq-accordion-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  width: min(900px, 95vw);
  max-height: 85vh;
  overflow: auto;
  background: var(--bg-secondary);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal header {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 20px 24px;
  z-index: 10;
}

.modal h3 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.modal .body {
  padding: 24px;
}

.modal .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.modal .meta .chip {
  background: rgba(0, 255, 0, 0.15);
  border: 1px solid rgba(0, 255, 0, 0.3);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  color: var(--txt);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tab.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.tabpanel {
  display: none;
}

.tabpanel.active {
  display: block;
}

.tabpanel p {
  margin: 0 0 16px 0;
  line-height: 1.6;
}

.tabpanel ul {
  margin: 0;
  padding-left: 20px;
}

.tabpanel li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.link {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  display: block;
  margin-bottom: 8px;
  transition: color 0.2s ease;
}

.link:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  font-size: 16px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .site-header {
    padding: 16px 20px;
  }

  body.theme-codex .site-header {
    border-radius: 0;
  }

  .basket-widget-floating {
    width: calc(100% - 32px);
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .title h1 {
    font-size: 22px;
  }

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

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

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

  main {
    padding: 24px 16px 120px 16px;
  }

  body.theme-codex #mainContent {
    margin: 0;
    padding: 32px 20px 100px 20px;
    border-radius: 24px;
  }

  body.theme-codex[data-layout="sidebar"] #mainContent {
    margin-left: 0;
    margin-right: 0;
  }
}

/* ===== KNOWLEDGE GRAPH ===== */
.knowledge-graph-view {
  position: relative;
  width: calc(100vw - var(--sidebar-width));
  max-width: none;
  padding: 0 var(--graph-padding-x);
  box-sizing: border-box;
}

body[data-layout="sidebar"] .knowledge-graph-view {
  width: calc(100vw - var(--sidebar-width));
}

.knowledge-graph-container {
  width: 100%;
  min-height: 450px;
  height: calc(100vh - 200px);
  max-height: 600px;
  position: relative;
  background: radial-gradient(circle at 50% 50%, rgba(88, 166, 255, 0.05), transparent 70%);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

body.theme-codex .knowledge-graph-container {
  border-radius: 32px;
  background: radial-gradient(circle at 20% 20%, rgba(16, 185, 129, 0.18), transparent 50%),
    radial-gradient(circle at 80% 0%, rgba(34, 197, 94, 0.16), transparent 45%),
    #ffffff;
  box-shadow: var(--shadow);
}

#knowledge-graph {
  width: 100%;
  height: 100%;
}

.graph-node {
  cursor: pointer;
  transition: all 0.3s ease;
}

.node-rect {
  fill: var(--card);
  stroke-width: 2.5;
  transition: all 0.3s ease;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.graph-node:hover .node-rect {
  fill: rgba(88, 166, 255, 0.15);
  stroke-width: 3;
  filter: drop-shadow(0 4px 12px rgba(88, 166, 255, 0.4));
}

.graph-node:hover .node-label {
  font-size: 16px;
  font-weight: 700;
}

.node-label {
  fill: var(--txt-heading);
  font-size: 14px;
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
  transition: all 0.3s ease;
}

.graph-arrow {
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
  opacity: 0.7;
  transition: all 0.3s ease;
}

.graph-arrow-head {
  fill: var(--accent);
  opacity: 0.9;
  transition: all 0.3s ease;
}

.graph-node:hover ~ .graph-arrow,
.graph-arrow:hover {
  opacity: 1;
  stroke-width: 2.5;
}

.graph-arrow:hover + .graph-arrow-head {
  opacity: 1;
}

.graph-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-anchor: start;
  pointer-events: none;
  opacity: 0.8;
  letter-spacing: 0.3px;
}

/* ===== GROUP CONTENT VIEW ===== */
.group-content-view {
  animation: fadeIn 0.5s ease;
}

.group-content-container {
  max-width: 1200px;
  margin: 0 auto;
}

.content-header {
  margin-bottom: 32px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--muted);
}

.breadcrumb-item {
  transition: color 0.2s ease;
}

.breadcrumb-item.active {
  color: var(--txt-heading);
  font-weight: 500;
}

.breadcrumb-separator {
  color: var(--border);
}

.content-header h1 {
  margin: 0;
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  grid-auto-flow: dense;
}

.content-item-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
  padding: 18px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.content-item-card.in-basket {
  border-color: var(--accent);
  box-shadow: 0 15px 35px rgba(88, 166, 255, 0.25);
}

body.theme-codex .content-item-card.in-basket {
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 20px 45px rgba(16, 185, 129, 0.25);
}

.content-item-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.content-item-card h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--txt-heading);
  line-height: 1.3;
}

.content-item-card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.content-item-card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.content-item-card .tag {
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.item-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.item-actions .btn-secondary {
  flex: 1;
  padding: 7px 10px;
  font-size: 12px;
}

.btn-add-basket.is-active {
  background: var(--accent);
  color: var(--bg);
  border: none;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.25);
}
