/* =========================================================
   SKEUOMORPHIC COMPONENTS & VISUAL TREE VIEW
   Layout, Tree View, Grid Cards, Segmented Controls & Modals
   ========================================================= */

/* App Container Layout */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  padding: 18px;
  gap: 18px;
  position: relative;
  overflow: hidden;
}

/* ---------------------------------------------------------
   SIDEBAR (TACTILE BINDER)
   --------------------------------------------------------- */
.sidebar {
  width: 320px;
  min-width: 280px;
  max-width: 360px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  user-select: none;
  z-index: 10;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 2px solid #dce2ea;
  margin-bottom: 14px;
  position: relative;
}

.sidebar-header::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 1px;
  background: #ffffff;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-plate {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  border-top: 1px solid #fef9c3;
  border-left: 1px solid #fef9c3;
  border-bottom: 2px solid #b45309;
  border-right: 1.5px solid #b45309;
  box-shadow: 2px 3px 6px #cbd3de, -2px -2px 5px #ffffff;
}

.brand-info h1 {
  font-size: 1.12rem;
  font-weight: 800;
  color: #1e293b;
  text-shadow: 0 1px 0 #ffffff;
  letter-spacing: -0.01em;
}

.brand-info span {
  font-size: 0.74rem;
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Quick Navigation */
.quick-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  background: linear-gradient(180deg, #ffffff 0%, #edf2f7 100%);
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-bottom: 1.5px solid #cbd5e1;
  border-right: 1.5px solid #cbd5e1;
  box-shadow: 1.5px 2px 4px #cbd5e1, -1.5px -1.5px 4px #ffffff;
  transition: all var(--tactile-spring);
}

.nav-item:hover {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.nav-item.active {
  background: linear-gradient(180deg, #dbe2ea 0%, #edf2f7 100%);
  color: var(--accent-blue);
  box-shadow: var(--skeuo-recessed);
  border-top: 1px solid #b4becb;
  border-left: 1px solid #b4becb;
  border-bottom: 1px solid #ffffff;
  border-right: 1px solid #ffffff;
  transform: translateY(1px);
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-pill {
  font-size: 0.74rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #e2e8f0;
  box-shadow: inset 1px 1px 2px #cbd5e1, inset -1px -1px 2px #ffffff;
  color: var(--text-secondary);
}

.nav-item.active .count-pill {
  background: #dbeafe;
  color: var(--accent-blue);
  box-shadow: inset 1px 1px 2px #bfdbfe, inset -1px -1px 2px #ffffff;
}

/* Sidebar Section Title */
.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  text-shadow: 0 1px 0 #ffffff;
}

/* Folder Tree Sidebar Container */
.folder-tree-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.tree-node {
  margin-bottom: 3px;
}

.tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--tactile-spring);
}

.tree-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.tree-item.active {
  background: #dbeafe;
  color: var(--accent-blue);
  border: 1px solid #bfdbfe;
  box-shadow: inset 1px 1px 3px rgba(37, 99, 235, 0.15);
}

.tree-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: #e2e8f0;
  box-shadow: 1px 1px 2px #cbd5e1, -1px -1px 2px #ffffff;
  font-size: 0.65rem;
  color: #475569;
  transition: transform var(--tactile-spring);
}

.chevron.open {
  transform: rotate(90deg);
}

.chevron.empty {
  visibility: hidden;
}

.tree-children {
  padding-left: 14px;
  margin-left: 8px;
  border-left: 2px solid #cbd5e1;
  display: none;
}

.tree-children.open {
  display: block;
}

/* Sidebar Footer */
.sidebar-footer {
  padding-top: 14px;
  border-top: 2px solid #dce2ea;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.sidebar-footer::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 0;
  width: 100%;
  height: 1px;
  background: #ffffff;
}

/* ---------------------------------------------------------
   MAIN WRAPPER & TOP HEADER
   --------------------------------------------------------- */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.top-header {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  margin-bottom: 16px;
  gap: 16px;
  z-index: 5;
}

/* Recessed Search Bar */
.search-container {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 44px;
}

.search-icon {
  font-size: 1.1rem;
  color: #64748b;
  margin-right: 10px;
}

.search-input {
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  width: 100%;
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-shortcut-badge {
  font-size: 0.72rem;
  font-weight: 800;
  color: #475569;
  background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 100%);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  box-shadow: 1px 1px 2px #cbd5e1;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
}

/* View Mode Segmented Controls */
.view-mode-selector {
  display: flex;
  align-items: center;
  background: #e2e8f0;
  box-shadow: var(--skeuo-recessed);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.view-mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  color: #475569;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--tactile-spring);
}

.view-mode-btn.active {
  background: linear-gradient(180deg, #ffffff 0%, #edf2f7 100%);
  color: var(--accent-blue);
  box-shadow: 2px 2px 4px #cbd5e1, -1px -1px 2px #ffffff;
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------------------------------------------------------
   CONTENT BODY AREA
   --------------------------------------------------------- */
.content-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 28px;
  overflow-y: auto;
  position: relative;
}

/* Action Toolbar (Breadcrumbs & Tree Actions) */
.toolbar-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1.5px solid #dce2ea;
}

.breadcrumb-trail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.crumb-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border: 1px solid #cbd5e1;
  box-shadow: 1px 1px 3px #cbd5e1, -1px -1px 2px #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
}

.crumb-item:hover {
  background: #ffffff;
  color: var(--accent-blue);
}

.crumb-item.current {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: var(--accent-blue);
  cursor: default;
}

.tree-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------------------------------------------------------
   🌳 VISUAL HIERARCHICAL TREE VIEW COMPONENT
   Connecting branch lines (├──), folders, and website leaf nodes
   --------------------------------------------------------- */
.tree-diagram {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tree-branch {
  position: relative;
}

.tree-branch-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-bottom: 1.5px solid #cbd5e1;
  border-right: 1.5px solid #cbd5e1;
  box-shadow: 2px 3px 6px #cbd5e1, -2px -2px 5px #ffffff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  width: fit-content;
  max-width: 100%;
  transition: all var(--tactile-spring);
}

.tree-branch-header:hover {
  background: #ffffff;
  box-shadow: 3px 4px 8px #c2c9d5, -3px -3px 6px #ffffff;
  transform: translateY(-1px);
}

.tree-branch-toggle-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  box-shadow: inset 1px 1px 2px #cbd5e1, inset -1px -1px 2px #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #334155;
  transition: transform var(--tactile-spring);
}

.tree-branch.collapsed > .tree-branch-header .tree-branch-toggle-btn {
  transform: rotate(-90deg);
}

.tree-branch-title {
  font-size: 0.94rem;
  font-weight: 800;
  color: #1e293b;
  text-shadow: 0 1px 0 #ffffff;
}

.tree-branch-count {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #64748b;
  box-shadow: inset 1px 1px 2px #cbd5e1, inset -1px -1px 2px #ffffff;
}

/* Branch Children Container with Connecting Lines */
.tree-branch-children {
  position: relative;
  padding-left: 24px;
  margin-left: 14px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tree-branch.collapsed > .tree-branch-children {
  display: none;
}

/* Connector Line for each child */
.tree-node-row {
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Continuous vertical connector */
.tree-node-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: -20px;
  width: 2px;
  height: 100%;
  background: #cbd5e1;
}

/* Last child: stop vertical line at the horizontal arm */
.tree-node-row:last-child::before {
  height: 20px;
}

/* Horizontal connector arm */
.tree-node-row::after {
  content: '';
  position: absolute;
  top: 19px;
  left: -20px;
  width: 18px;
  height: 2px;
  background: #cbd5e1;
}

/* Website Leaf Node in the Tree */
.tree-leaf-site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-bottom: 1.5px solid #d1d5db;
  border-right: 1.5px solid #d1d5db;
  border-radius: var(--radius-sm);
  box-shadow: 2px 2px 5px #cbd5e1, -1px -1px 3px #ffffff;
  transition: all var(--tactile-spring);
  width: fit-content;
  min-width: 280px;
  max-width: 620px;
}

.tree-leaf-site:hover {
  background: #ffffff;
  transform: translateX(3px);
  box-shadow: 3px 4px 8px #c2c9d5, -2px -2px 5px #ffffff;
  border-color: #93c5fd;
}

.tree-leaf-site.search-match {
  background: linear-gradient(180deg, #fef9c3 0%, #fef08a 100%);
  border-color: #facc15;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.3), 2px 3px 6px #cbd5e1;
}

.tree-leaf-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.tree-leaf-favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.tree-leaf-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-leaf-domain {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent-blue);
  background: #eff6ff;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #dbeafe;
}

.tree-leaf-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ---------------------------------------------------------
   🗂️ DESK GRID VIEW (TACTILE PHYSICAL CARDS)
   --------------------------------------------------------- */
.grid-mode-active .tree-actions {
  display: none !important;
}

.subfolders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  padding-top: 6px;
}

.subfolder-card {
  padding: 14px 16px;
  border-radius: 4px 14px 10px 10px;
  background: linear-gradient(180deg, #ffffff 0%, #edf2f7 100%);
  border-top: 1.5px solid #ffffff;
  border-left: 1.5px solid #ffffff;
  border-bottom: 2px solid #cbd5e1;
  border-right: 1.5px solid #cbd5e1;
  box-shadow: 2px 3px 6px #cbd5e1, -2px -2px 5px #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all var(--tactile-spring);
  position: relative;
}

.subfolder-card::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 8px;
  width: 50px;
  height: 7px;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-top: 1.5px solid #ffffff;
  border-left: 1.5px solid #ffffff;
  border-right: 1.5px solid #cbd5e1;
  border-radius: 5px 5px 0 0;
}

.subfolder-card:hover {
  background: #ffffff;
  transform: translateY(-2px);
  box-shadow: 3px 6px 12px #c2c9d5, -3px -3px 6px #ffffff;
}

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

.site-card {
  display: flex;
  flex-direction: column;
  padding: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-top: 1.5px solid #ffffff;
  border-left: 1.5px solid #ffffff;
  border-bottom: 2px solid #cbd5e1;
  border-right: 1.5px solid #cbd5e1;
  box-shadow: var(--skeuo-extruded-card);
  position: relative;
  transition: all var(--tactile-spring);
}

.site-card:hover {
  transform: translateY(-3px);
  box-shadow: 6px 10px 18px rgba(160, 174, 192, 0.5), -4px -4px 10px #ffffff;
}

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

.site-favicon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-bottom: 1.5px solid #cbd5e1;
  border-right: 1.5px solid #cbd5e1;
  box-shadow: 2px 2px 5px #cbd5e1;
  flex-shrink: 0;
}

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

.fav-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  color: #cbd5e1;
  transition: transform var(--tactile-spring), color var(--tactile-spring);
}

.fav-btn:hover {
  transform: scale(1.2);
  color: #fbbf24;
}

.fav-btn.is-fav {
  color: #f59e0b;
  text-shadow: 0 1px 2px rgba(217, 119, 6, 0.4);
}

.site-body {
  flex: 1;
  margin-bottom: 14px;
}

.site-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 5px;
  text-shadow: 0 1px 0 #ffffff;
}

.site-domain-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent-blue);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.site-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.site-folder-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  margin-top: 6px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
  gap: 8px;
}

/* ---------------------------------------------------------
   EMPTY STATE
   --------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-icon-plate {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 100%);
  border-top: 1.5px solid #ffffff;
  border-left: 1.5px solid #ffffff;
  border-bottom: 2px solid #cbd5e1;
  border-right: 2px solid #cbd5e1;
  box-shadow: 4px 6px 14px #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin-bottom: 16px;
}

/* ---------------------------------------------------------
   SKEUOMORPHIC MODALS
   --------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  width: 100%;
  max-width: 480px;
  background: #eef2f7;
  border-radius: var(--radius-lg);
  border-top: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #b8c2cf;
  border-right: 2px solid #b8c2cf;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  padding: 28px;
}

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

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #1e293b;
  text-shadow: 0 1px 0 #ffffff;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  color: #475569;
  text-shadow: 0 1px 0 #ffffff;
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1.5px solid #cbd5e1;
  border-left: 1.5px solid #cbd5e1;
  border-bottom: 1px solid #ffffff;
  border-right: 1px solid #ffffff;
  box-shadow: inset 2px 2px 4px #e2e8f0;
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: inset 2px 2px 4px #dbeafe, 0 0 0 2px rgba(37, 99, 235, 0.2);
}

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

/* ---------------------------------------------------------
   SKEUOMORPHIC CUSTOM SELECT DROPDOWN
   --------------------------------------------------------- */
.custom-select-wrapper {
  position: relative;
  width: 100%;
  user-select: none;
}

.custom-select-native {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  clip: rect(0, 0, 0, 0) !important;
}

.custom-select-trigger {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px 8px 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-top: 1.5px solid #cbd5e1;
  border-left: 1.5px solid #cbd5e1;
  border-bottom: 1.5px solid #ffffff;
  border-right: 1.5px solid #ffffff;
  box-shadow: inset 1px 1px 3px #e2e8f0, 1px 1px 2px #ffffff;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e293b;
  transition: all var(--tactile-spring);
  text-align: left;
}

.custom-select-trigger:hover {
  background: #ffffff;
  border-color: #94a3b8;
}

.custom-select-wrapper.open .custom-select-trigger {
  border-color: var(--accent-blue);
  box-shadow: inset 2px 2px 4px #dbeafe, 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.custom-select-trigger-content {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.custom-select-trigger-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.custom-select-trigger-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-arrow {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #e2e8f0;
  box-shadow: 1px 1px 2px #cbd5e1, -1px -1px 2px #ffffff;
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: #475569;
  flex-shrink: 0;
  transition: transform var(--tactile-spring), color var(--tactile-spring), background var(--tactile-spring);
}

.custom-select-wrapper.open .custom-select-arrow {
  transform: rotate(180deg);
  background: #dbeafe;
  color: var(--accent-blue);
  border-color: #bfdbfe;
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  max-width: 100%;
  background: #eef2f7;
  border-radius: 10px;
  border-top: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #cbd5e1;
  border-right: 2px solid #cbd5e1;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.2), 2px 4px 10px #cbd5e1;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.custom-select-wrapper.open .custom-select-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.custom-select-search-wrap {
  padding: 8px 10px;
  background: #e2e8f0;
  border-bottom: 1.5px solid #cbd5e1;
}

.custom-select-search {
  width: 100%;
  height: 34px;
  padding: 6px 10px;
  background: #ffffff;
  border-top: 1.5px solid #cbd5e1;
  border-left: 1.5px solid #cbd5e1;
  border-bottom: 1px solid #ffffff;
  border-right: 1px solid #ffffff;
  box-shadow: inset 1px 1px 3px #e2e8f0;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1e293b;
  outline: none;
}

.custom-select-search:focus {
  border-color: var(--accent-blue);
  box-shadow: inset 1px 1px 3px #dbeafe, 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.custom-select-list {
  max-height: 230px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.custom-select-list::-webkit-scrollbar {
  width: 6px;
}

.custom-select-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.custom-select-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
  color: #334155;
  transition: all var(--tactile-spring);
  border: 1px solid transparent;
  gap: 8px;
}

.custom-select-item:hover {
  background: #ffffff;
  color: #0f172a;
  transform: translateX(2px);
  border-color: #cbd5e1;
  box-shadow: 1px 2px 4px rgba(148, 163, 184, 0.2);
}

.custom-select-item.selected {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
  box-shadow: inset 1px 1px 2px rgba(37, 99, 235, 0.15);
}

.custom-select-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.custom-select-item-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.custom-select-item-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-item-check {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-blue);
  opacity: 0;
  flex-shrink: 0;
}

.custom-select-item.selected .custom-select-item-check {
  opacity: 1;
}

.custom-select-empty {
  padding: 18px 12px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: #94a3b8;
}

/* ---------------------------------------------------------
   CONTINUOUS TREE CONNECTOR LINES (Picture 2 Style)
   --------------------------------------------------------- */
.cs-node {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.cs-children {
  position: relative;
  padding-left: 20px;
  margin-left: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 3px;
}

.cs-node-row {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Continuous vertical connector line */
.cs-node-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: -14px;
  width: 2px;
  height: 100%;
  background: #cbd5e1;
}

/* Last child stops vertical line at the horizontal arm (no dangling line) */
.cs-node-row:last-child::before {
  height: 18px;
}

/* Horizontal connector arm branching directly into the node */
.cs-node-row::after {
  content: '';
  position: absolute;
  top: 17px;
  left: -14px;
  width: 12px;
  height: 2px;
  background: #cbd5e1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ---------------------------------------------------------
   TOAST NOTIFICATIONS
   --------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #edf2f7 100%);
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-bottom: 2px solid #cbd5e1;
  border-right: 1.5px solid #cbd5e1;
  box-shadow: 4px 6px 14px rgba(71, 85, 105, 0.25);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.removing {
  opacity: 0;
  transform: translateY(10px);
}

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

/* ---------------------------------------------------------
   RESPONSIVE DESIGN (Phone, Tablet, Laptop, Desktop PC)
   --------------------------------------------------------- */

/* Default states for mobile controls on Desktop (hidden on PC/laptop) */
.mobile-top-bar {
  display: none;
}

.mobile-sidebar-close {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

/* 1. Laptops & Compact Desktops (1024px - 1280px) */
@media (max-width: 1280px) {
  .sidebar {
    width: 280px;
    min-width: 260px;
  }
  .websites-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
  }
}

/* 2. Tablets (Landscape & Portrait) & Small Laptops (769px - 1023px) */
@media (max-width: 1023px) {
  .app-layout {
    padding: 12px;
    gap: 12px;
  }
  .sidebar {
    width: 260px;
    min-width: 240px;
    padding: 16px 12px;
  }
  .top-header {
    padding: 0 16px;
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .search-container {
    max-width: 320px;
  }
  .view-mode-selector {
    padding: 3px;
  }
  .view-mode-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
  }
  .websites-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
  }
}

/* 3. Mobile Devices & Tablet Portrait (<= 900px) */
@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
    padding: 10px;
    gap: 10px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* Mobile Top Bar inside Header */
  .mobile-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 4px;
  }

  .mobile-brand-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    text-shadow: 0 1px 0 #ffffff;
  }

  .mobile-sidebar-close {
    display: inline-flex;
  }

  /* Off-Canvas Slide-out Drawer Sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 86%;
    max-width: 340px;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    z-index: 2000;
    transform: translateX(-105%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 12px 0 40px rgba(15, 23, 42, 0.35);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    background: #eef2f7;
    overflow-y: auto;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Sidebar Backdrop */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Main Wrapper */
  .main-wrapper {
    flex: 1;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* Top Header Controls on Mobile */
  .top-header {
    height: auto;
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
  }

  .top-header .header-actions {
    display: none; /* Add button is in .mobile-top-bar */
  }

  .search-container {
    max-width: 100%;
    width: 100%;
  }

  .search-input-wrapper {
    height: 42px;
    padding: 0 12px;
  }

  .search-input {
    font-size: 16px; /* Prevents auto-zoom in iOS Safari */
  }

  .search-shortcut-badge {
    display: none; /* Hide Ctrl K on touch/mobile */
  }

  .view-mode-selector {
    width: 100%;
    justify-content: space-between;
    padding: 3px;
  }

  .view-mode-btn {
    flex: 1;
    justify-content: center;
    padding: 8px 6px;
    font-size: 0.8rem;
    font-weight: 700;
  }

  /* Content Body */
  .content-body {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Breadcrumbs on Mobile */
  .toolbar-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
  }

  .breadcrumb-trail {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .breadcrumb-trail::-webkit-scrollbar {
    display: none;
  }

  .tree-actions {
    width: 100%;
    justify-content: space-between;
  }

  /* Grid & Cards on Mobile */
  .subfolders-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }

  .subfolder-card {
    padding: 12px 14px;
  }

  .websites-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .site-card {
    padding: 16px;
  }

  /* Tree Diagram on Mobile */
  .tree-diagram {
    gap: 10px;
  }

  .tree-branch-header {
    padding: 8px 12px;
    max-width: 100%;
  }

  .tree-branch-title {
    font-size: 0.88rem;
  }

  .tree-branch-children {
    padding-left: 16px;
    margin-left: 8px;
    gap: 6px;
  }

  .tree-node-row::before {
    left: -14px;
  }

  .tree-node-row::after {
    left: -14px;
    width: 12px;
  }

  .tree-leaf-site {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
    gap: 8px;
  }

  .tree-leaf-name {
    font-size: 0.82rem;
  }

  /* Chart View on Mobile */
  .chart-canvas-wrapper {
    min-height: 420px;
    height: 420px;
  }

  .chart-floating-controls {
    top: 10px;
    right: 10px;
  }

  /* Modals on Mobile */
  .modal-box {
    width: 95vw;
    max-width: 440px;
    padding: 20px 16px;
    margin: 10px auto;
  }

  .modal-title {
    font-size: 1.05rem;
  }

  /* Toast on Mobile */
  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    padding: 10px 14px;
    font-size: 0.82rem;
  }
}

/* 4. Small Phones (<= 480px) */
@media (max-width: 480px) {
  .app-layout {
    padding: 6px;
    gap: 8px;
  }

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

  .view-mode-btn {
    padding: 7px 4px;
    font-size: 0.74rem;
    gap: 4px;
  }

  .site-card {
    padding: 14px;
  }

  .site-title {
    font-size: 0.94rem;
  }

  .site-domain-badge {
    font-size: 0.72rem;
  }

  .modal-box {
    width: 96vw;
    padding: 18px 14px;
  }
}


/* ---------------------------------------------------------
   🕸️ HORIZONTAL BRANCHING CHART VIEW (MIND MAP)
   --------------------------------------------------------- */
.chart-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 520px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: #e9edf3;
  background-image: radial-gradient(#cbd5e1 1.2px, transparent 1.2px);
  background-size: 20px 20px;
  border-top: 1.5px solid #cbd5e1;
  border-left: 1.5px solid #cbd5e1;
  border-bottom: 1.5px solid #ffffff;
  border-right: 1.5px solid #ffffff;
  box-shadow: inset 2px 2px 6px #d8e0ea, inset -2px -2px 6px #ffffff;
  touch-action: none;
}

.chart-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.chart-curve-link {
  stroke: #94a3b8;
  stroke-width: 2px;
  fill: none;
  transition: stroke 0.2s, stroke-width 0.2s;
}

.chart-curve-link:hover {
  stroke: #2563eb;
  stroke-width: 3px;
}

.chart-curve-link.match-link {
  stroke: #f59e0b;
  stroke-width: 3px;
}

.chart-node-circle {
  transition: transform 0.2s, r 0.2s;
}

.root-circle {
  fill: #8b5cf6;
  stroke: #ffffff;
  stroke-width: 2.5px;
  filter: drop-shadow(0 2px 4px rgba(139, 92, 246, 0.4));
}

.folder-circle {
  fill: #3b82f6;
  stroke: #ffffff;
  stroke-width: 2px;
  filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.35));
  cursor: pointer;
}

.leaf-circle {
  fill: #10b981;
  stroke: #ffffff;
  stroke-width: 2px;
  filter: drop-shadow(0 2px 4px rgba(16, 185, 129, 0.35));
}

.chart-node:hover .chart-node-circle {
  transform: scale(1.3);
}

.chart-node-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: linear-gradient(180deg, #ffffff 0%, #edf2f7 100%);
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-bottom: 1.5px solid #cbd5e1;
  border-right: 1.5px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 1.5px 2px 4px #cbd5e1, -1px -1px 2px #ffffff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
}

.chart-node-label:hover {
  background: #ffffff;
  transform: translateY(-1.5px);
  box-shadow: 2px 4px 8px #cbd5e1;
  border-color: #93c5fd;
}

.chart-node-label.highlight {
  background: linear-gradient(180deg, #fef9c3 0%, #fef08a 100%);
  border-color: #facc15;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.3);
}

.chart-site-domain {
  font-size: 0.7rem;
  color: #2563eb;
  background: #eff6ff;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid #dbeafe;
}

.chart-visit-icon {
  color: #2563eb;
  text-decoration: none;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 1px 5px;
  border-radius: 4px;
  transition: all 0.15s;
}

.chart-visit-icon:hover {
  background: #2563eb;
  color: #ffffff;
}

.chart-badge-collapsed {
  font-size: 0.68rem;
  color: #ffffff;
  background: #3b82f6;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 800;
}

.chart-floating-controls {
  position: absolute;
  top: 16px;
  right: 18px;
  display: flex;
  gap: 6px;
  z-index: 50;
  background: rgba(238, 242, 247, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px;
  border-radius: var(--radius-sm);
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-bottom: 1px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
  box-shadow: 2px 4px 10px rgba(100, 116, 139, 0.2);
}


/* ---------------------------------------------------------
   SIDEBAR ACTIVE PATH SUBFOLDERS ACCORDION
   --------------------------------------------------------- */
.sidebar-cat-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-subfolders-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 14px;
  margin-left: 12px;
  border-left: 2px solid #cbd5e1;
  margin-top: 2px;
  margin-bottom: 6px;
}

.sidebar-subfolders-nested {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 12px;
  margin-left: 8px;
  border-left: 2px solid #bfdbfe;
  margin-top: 2px;
  margin-bottom: 4px;
}

.sidebar-sub-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-bottom: 1.5px solid #d1d5db;
  border-right: 1.5px solid #d1d5db;
  box-shadow: 1px 1px 3px #cbd5e1, -1px -1px 2px #ffffff;
  transition: all var(--tactile-spring);
}

.sidebar-sub-item:hover {
  background: #ffffff;
  color: var(--text-primary);
  transform: translateX(2px);
  border-color: #93c5fd;
}

.sidebar-sub-item.active {
  background: linear-gradient(180deg, #dbeafe 0%, #eff6ff 100%);
  color: var(--accent-blue);
  border: 1px solid #93c5fd;
  box-shadow: inset 1px 1px 3px rgba(37, 99, 235, 0.2);
  transform: translateY(1px);
}

.sidebar-sub-item.active .count-pill {
  background: #bfdbfe;
  color: #1d4ed8;
  box-shadow: inset 1px 1px 2px #93c5fd, inset -1px -1px 2px #ffffff;
}

.sidebar-sub-item.in-path {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--accent-blue);
}

.sidebar-sub-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sidebar-sub-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-sub-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
