:root {
  /* Clean Palette - Light Mode Default */
  --primary: #2563eb; /* Blue 600 */
  --primary-hover: #1d4ed8; /* Blue 700 */
  --primary-light: #eff6ff; /* Blue 50 */
  
  --danger: #dc2626; /* Red 600 */
  --danger-hover: #b91c1c; /* Red 700 */
  --danger-light: #fef2f2; /* Red 50 */

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f3f4f6; /* Gray 100 */
  --border: #e5e7eb; /* Gray 200 */
  
  --text: #111827; /* Gray 900 */
  --text-muted: #6b7280; /* Gray 500 */
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --radius: 6px;
  --transition: all 0.15s ease-in-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Standard, legible Dark Mode */
    --primary: #3b82f6; /* Blue 500 */
    --primary-hover: #60a5fa; /* Blue 400 */
    --primary-light: rgba(59, 130, 246, 0.15);
    
    --danger: #ef4444; /* Red 500 */
    --danger-hover: #f87171; /* Red 400 */
    --danger-light: rgba(239, 68, 68, 0.15);

    --bg: #1f2937; /* Gray 800 */
    --surface: #374151; /* Gray 700 */
    --surface-hover: #4b5563; /* Gray 600 */
    --border: #4b5563; /* Gray 600 */
    
    --text: #f9fafb; /* Gray 50 */
    --text-muted: #9ca3af; /* Gray 400 */
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  width: 340px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Typography & Layout */
.row { display: flex; align-items: center; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.tab-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-hover);
  padding: 4px 8px;
  border-radius: var(--radius);
}

/* Panels */
.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel h2, .panel-head h2 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Buttons */
.grid { display: grid; gap: 8px; }
.grid.three { grid-template-columns: repeat(3, 1fr); }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.btn svg {
  width: 16px; height: 16px;
  color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  border: transparent;
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--surface-hover);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-light);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn-danger svg { color: currentColor; }

/* Search */
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Results */
.results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 250px;
  overflow-y: auto;
}

.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.result-item:hover {
  border-color: var(--text-muted);
}

.favicon {
  width: 16px; height: 16px;
  border-radius: 2px;
}

.result-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.result-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.result-url {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Row Actions */
.mini-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
}
.mini-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.mini-btn.close-btn:hover { color: var(--danger); }
.mini-btn.focus-btn:hover { color: var(--primary); }

/* Indicators */
.tag-icon { width: 14px; height: 14px; color: var(--text-muted); }
.tag-icon.warning { color: #f59e0b; }

/* Status Toast */
.status {
  position: fixed;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  box-shadow: var(--shadow);
}
.status.show { opacity: 1; }