:root {
  --bg-app: #f5f5f7;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff; /* Or slightly different */
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --accent: #007aff;
  --accent-hover: #0062cc;
  --border: #d2d2d7;
  --border-light: rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 4px;
  --header-height: 60px;
  --sidebar-width: 300px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden; /* No global scroll */
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background-color: #f5f5f7; /* IE11 Fallback */
  background-color: var(--bg-app);
  color: #1d1d1f; /* IE11 Fallback */
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* --- Layout --- */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* --- Sidebar --- */
.app-sidebar {
  width: 300px; /* IE11 Fallback */
  width: var(--sidebar-width);
  background: #ffffff; /* IE11 Fallback */
  background: var(--bg-sidebar);
  border-right: 1px solid #d2d2d7; /* IE11 Fallback */
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 90;
}

.sidebar-content {
  padding: 24px;
}

.sidebar-section {
  margin-bottom: 32px;
}

.sidebar-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin: 0 0 16px 0;
  font-weight: 600;
}

.desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 16px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 12px;
}

.sidebar-footer p {
  margin: 2px 0;
}

/* --- Content Area --- */
.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f5f5f7; /* IE11 Fallback */
  background: var(--bg-app);
  position: relative;
}

/* --- Toolbar --- */
.toolbar {
  background: rgba(245, 245, 247, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-light);
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 80;
  flex-shrink: 0;
}

.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.toolbar-row.secondary {
  justify-content: flex-start;
}

.stats-bar {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --- List --- */
.list-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  /* Scrollbar Styling */
  scrollbar-width: thin;
  scrollbar-color: #c1c1c1 transparent;
}

.list-container::-webkit-scrollbar {
  width: 8px;
}
.list-container::-webkit-scrollbar-track {
  background: transparent;
}
.list-container::-webkit-scrollbar-thumb {
  background-color: #c1c1c1;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* --- Components --- */
/* Header */
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--text-primary);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.header-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.status-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  background: #e1f5ea;
  color: #1a7f47;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  border: none;
  gap: 8px;
}
.btn.primary {
  background: var(--accent);
  color: white;
}
.btn.primary:hover {
  background: var(--accent-hover);
}
.btn.outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn.outline:hover {
  background: rgba(0,0,0,0.02);
  border-color: var(--text-secondary);
}
.btn.full-width {
  width: 100%;
}
.icon-btn {
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.icon-btn:hover {
  background: rgba(0,0,0,0.05);
}

/* Segmented Control */
.seg-control {
  background: #e5e5ea;
  padding: 2px;
  border-radius: 8px;
  display: inline-flex;
}
.seg-btn {
  border: none;
  background: transparent;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}
.seg-btn.is-active {
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Inputs & Filters */
.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}
.search-wrapper input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease-in-out;
}
.search-wrapper input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}

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

.select-clean {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 32px 6px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  line-height: 1.5;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2386868B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  outline: none;
}
.select-clean:hover {
  border-color: var(--text-secondary);
}
.select-clean:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0,122,255,0.1);
}

/* Nav Links */
.nav-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid var(--border-light);
  transition: transform 0.2s, box-shadow 0.2s;
}
.nav-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.nav-title {
  font-weight: 500;
  color: var(--text-primary);
}
.nav-url {
  font-size: 12px;
  color: var(--text-secondary);
}

/* List Item (Flat List) */
.resource-list {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); /* Unified 2px blur shadow */
}

.item {
  background: white;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1); /* 20% opacity separator (approx) */
  transition: background-color 0.2s ease-in-out;
}

.item:last-child {
  border-bottom: none;
}

.item:hover {
  background-color: #f5f5f7;
}

.item .row {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.item .badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.badge.css { background: #e3f2fd; color: #1976d2; }
.badge.js { background: #fff3e0; color: #ef6c00; }

.item .url {
  font-family: monospace;
  font-size: 13px; /* Slightly larger for readability */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  flex: 1;
}

.item .meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

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

.btn.small {
  padding: 4px 10px;
  font-size: 12px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Ensure icon size consistency */
.item svg, .btn .icon {
  width: 16px;
  height: 16px;
}

/* Loading/Empty */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
  display: none; /* Hidden by default, toggled by JS */
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-sentinel { text-align: center; padding: 20px; }
.empty { text-align: center; color: var(--text-secondary); padding: 40px; background: var(--bg-card); border-radius: 12px; }

/* Search Hint */
.search-hint {
  text-align: center;
  padding: 16px;
  color: var(--text-secondary);
  font-size: 13px;
  background: rgba(255,255,255,0.5);
  margin-top: 1px;
  border-radius: 0 0 12px 12px;
}

/* Back Top */
.fab-btn {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: white;
  color: var(--accent);
  border: none;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
  pointer-events: none;
  z-index: 99;
}
.fab-btn.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  z-index: 2000;
  backdrop-filter: blur(10px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Responsive --- */
.mobile-only { display: none; }
.sidebar-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 85;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

/* Tablet (769px - 1024px) */
@media (max-width: 1024px) {
  :root { --sidebar-width: 240px; }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
  .mobile-only { display: flex; }
  
  .app-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 300px;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    background: white;
    z-index: 90;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  
  .app-sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .toolbar {
    padding: 12px 16px;
  }
  .toolbar-row {
    flex-wrap: wrap;
  }
  .search-wrapper {
    max-width: 100%;
    order: 1;
    width: 100%;
  }
  .filters {
    order: 2;
    width: 100%;
    display: flex;
    justify-content: space-between;
  }
  
  .app-header {
    padding: 0 16px;
  }
  
  .list-container {
    padding: 12px 16px;
  }
}

/* Toast (Bottom Right, Non-modal) */
.toast-br {
  position: fixed;
  bottom: 24px;
  right: 24px;
  transform: translateY(0);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 2000;
  backdrop-filter: blur(10px);
}
.toast-br.show {
  opacity: 1;
}

/* Button inner loading spinner (shown when .btn has .is-loading) */
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}
.btn.is-loading .btn-spinner {
  display: inline-block;
}
.btn.is-loading {
  opacity: 0.9;
  cursor: not-allowed;
}
